# Selecting points intersecting polygon

In ArcGIS 10.2 ArcMap am attempting to label a grid of varying size polygons overlaid by a grid of evenly spaced (1km) points with an associated value X by the the value of the point. If a polygon is intersected by more than 1 then I want it to be labelled with the maximum X value. If a polygon doesn't intersect with a point I want it to be labelled with the nearest point.

I used spatial join with one to one intersect and maximum value for X to be selected. This allowed me to get the maximum value for multiple points that intersected. However it doesn't allow me to label the polygons where a point does not intersect it. I put a search radius on it and then it can label polygons with points where X is greater but are not contained in the actual polygon.

It is not possible. Geoprocessing is meant to be done by piling many tools that do a limited number of things on top of each other, not by designing or using supertools that do many things. Even with python geometry methods and a cursor (which would be slower), you have to split the problem into at least 2 completely separate steps. Near and Spatial Join can't be done in a single step (unless you just wanted one of the points that fell inside or near the polygon without counting all of the points inside).

A spatial join involves matching rows from the Join Features to the Target Features based on their relative spatial locations.

By default, all attributes of the join features are appended to attributes of the target features and copied over to the output feature class. You can define which of the attributes will be written to the output by manipulating them in the Field Map of Join Features parameter.

Two new fields, Join_Count and TARGET_FID , are always added to the output feature class. Join_Count indicates how many join features match each target feature ( TARGET_FID ).

Another new field, JOIN_FID , is added to the output when JOIN_ONE_TO_MANY is specified in the Join Operation parameter.

When the Join Operation parameter is JOIN_ONE_TO_MANY , there can be more than one row in the output feature class for each target feature. The JOIN_FID field makes it easier to determine which feature is joined to which target feature ( TARGET_FID ). A value of -1 for JOIN_FID field means no feature meets the specified spatial relationship with the target feature.

• The Join Operation is set to JOIN_ONE_TO_ONE , and
• Keep All Target Features is checked ( join_type = "KEEP_ALL" in Python).

Merge rules specified in the Field Map of Join Features parameter only apply to attributes from the join features and when more than one feature is matched to a target feature (when Join_Count > 1). For example, if three features with DEPTH attribute values of 15.5, 2.5, and 3.3 are joined, and a merge rule of Mean is applied, the output field will have a value of 6.1. Null values in join fields are ignored for statistic calculation. For example, 15.5, <null>, and 2.5 will result in 9.0 for Mean and 2 for Count.

When the Match Option is set to CLOSEST or CLOSEST_GEODESIC , it is possible that two or more join features are at the same distance from the target feature. When this situation occurs, one of the join features is randomly selected as the matching feature (the join feature's FID does not influence this random selection). If you want to find the 2 nd , 3 rd , or N th closest feature, use the Generate Near Table tool.

If a join feature has a spatial relationship with multiple target features, then it is counted as many times as it is matched against the target feature. For example, if a point is within three polygons, then the point is counted three times, once for each polygon.

For more information about using the three-dimensional spatial relationships INTERSECT_3D and WITHIN_A_DISTANCE_3D see Select by Location 3D relationships.

Geometric intersection algorithms are fundamental in spatial analysis in Geographic Information System (GIS). Applying high performance computing to perform geometric intersection on huge amount of spatial data to get real-time results is necessary. Given two input geometries (polygon or polyline) of a candidate pair, we introduce a new two-step geospatial filter that first creates sketches of the geometries and uses it to detect workload and then refines the sketches by the common areas of sketches to decrease the overall computations in the refine phase. We call this filter PolySketch-based CMBR (PSCMBR) filter. We show the application of this filter in speeding-up line segment intersections (LSI) reporting task that is a basic computation in a variety of geospatial applications like polygon overlay and spatial join.

We also developed a parallel PolySketch-based PNP filter to perform PNP tests on GPU which reduces computational workload in PNP tests. Finally, we integrated these new filters to the hierarchical filter and refinement (HiFiRe) system to solve geometric intersection problem. We have implemented the new filter and refine system on GPU using CUDA. The new filters introduced in this paper reduce more computational workload when compared to existing filters. As a result, we get on average 7.96X speedup compared to our prior version of HiFiRe system.

ReQL geometry objects are not GeoJSON objects, but you can convert back and forth between them with the geojson and toGeojson commands.

RethinkDB only allows conversion of GeoJSON objects which have ReQL equivalents: Point, LineString, and Polygon MultiPoint, MultiLineString, and MultiPolygon are not supported. (You could, however, store multiple points, lines and polygons in an array and use a geospatial multi index with them.)

Only longitude/latitude coordinates are supported. GeoJSON objects that use Cartesian coordinates, specify an altitude, or specify their own coordinate reference system will be rejected.

How many dimensions are supported?

Two (latitude and longitude). Elevation is not supported.

What projections are supported?

RethinkDB supports the WGS84 World Geodetic System’s reference ellipsoid and geographic coordinate system (GCS). It does not directly support any projected coordinate system (PCS), but there are many tools available for performing such projections.

Does RethinkDB do a correct interpolation of degrees to meters along a path?

Yes. Distance calculations are done on a geodesic (either WGS84’s reference ellipsoid or a unit sphere).

Can you export to WKT or WKB?

No. However, you can export to GeoJSON and process that with other tools.

## CSE546: Computational Geometry ( Fall 2017 )

Time and location: T, Th 2:30-4pm in Duncker 101 .

Textbook: "Computational Geometry: Algorithms and Applications" , Third Edition. This textbook is required. It is a fantastic book, and relatively inexpensive. I also recommend reading Dave Mount's (wonderful) Lecture Notes.

Piazza: I encourage you all to post and answer questions on Piazza. While the TAs and I will try to be as responsive as we can, the collective wisdom of the class is a much better resource to explore.

Grading: Your grade depends on your performance on homework, exams, and (optionally) the final project. There will be four (4) homework and two (2) exams throughout the semester, all of which are completed individually in written form. The final project may involve programming and can be completed in a group of up to three people. Homeworks and exams have equal share in the final grade. Any submitted final project gets a perfect score, but its share in the final grade varies based on the difficulty of the project and how well it is done. The project's share may range between 0% and 40%. The actual formula can be found here. No late homeworks or projects are accepted.

Academic Integrity: You are required to be familiar with and follow the academic integrity policy, which is in turn similar to the policies of Jeremy Buhler in 441/541.

• Instructor: Prof. Tao Ju (taoju at cse.wustl.edu)
• Hours: Thursday 4p-5p (Jolley 406)
• Hours: Monday 9:30a-11a, Friday 2:30p-4p, Wednesday 10a-11:30a (Jolley 408)
###### Calendar

This is a day-by-day list of events happening in the semester, including lectures, homework out/due dates, exam dates, and project due date.

###### Lectures
• Lecture 1: Introduction and convex hulls (Slides) and convex hulls (Notes: Lecture 1 and first part of Lecture 3 Book: Chapter 1)
• Lecture 2: Relation between convex hull and sorting Relation between convex hull and sorting (Notes: last part of Lecture 3 and beginning of Lecture 4)
• Lecture 3: Output sensitive complexity and Chan's convex hull algorithm (Notes: most of Lecture 4 additional reading)
• Lecture 4: Line segment intersection Line segment intersection (Notes: Lecture 5 Book: Chapter 2.1)
• Lecture 5: Planar subdivisions (Notes: beginning of Lecture 6 and all of Lecture 23 Book: Chapter 2.2 and 2.3)
• Lecture 6: Art Gallery Theorem (Notes: rest of Lecture 6 Book: Chapter 3.1)
• Lecture 7: Polygon triangulation (Notes: Lecture 7 Book: Chapter 3.2 and 3.3 slides on monotone polygon triangulation The famous linear time algorithm)
• Lecture 8: Kirkpatrick's point location algorithm (Notes: Lecture 25 A cool demo)
• Lecture 9: Point location by trapezoidal decomposition (Notes: Lectures 14, 15 Book: Chapter 6.1, 6.2)
• Lecture 10: Voronoi diagrams (Notes: Lectures 16 first part Book: Chapter 7.1 a demo)
• Lecture 11: Delaunay triangulations (Notes: Lectures 17 first part Book: Chapter 9.1, 9.2)
• Lecture 12: Relation between Delaunay triangulations and convex hull (Notes: Lectures 28)
• EXAM 1 (Oct 10th) (practice problems and hints)
• Lecture 13: Fortune's algorithm for computing Voronoi diagrams (Notes: Lecture 16 second part Book: Chapter 7.2 a demo)
• Lecture 14: Incremental construction of Delaunay triangulations (Notes: Lecture 18 Book: Chapters 9.3, 9.4)
• Lecture 15:Alpha hulls and variations of Voronoi Diagrams (Slides)
• Lecture 16: Point/line duality (Notes: Lecture 8 Book: Chapter 8.2 a demo)
• Lecture 17: Ham Sandwitch Theorem and line arrangement (Notes: Lecture 30)
• Lecture 18: Zone Theorem and computing line arrangement (Notes: Lecture 19 Book: Chapter 8.3)
• Lecture 19: Applications of line arrangement (Notes: Lecture 20 Book: Chapter 8.1, 8.4)
• Lecture 20: 1D range queries and binary trees (Notes: first part of Lecture 11 Book: Chapter 5.1)
• Lecture 21: 2D range queries, Kd trees and Orthogonal range trees (Notes: latter part of Lecture 11, Lecture 12 Book: Chapter 5.2, 5.3 slides)
• Lecture 22: Interval trees (Notes: Lecture 24 Book: Chapter 10.1 slides )
• Lecture 23: Shortest paths and visibility graphs (Notes: Lecture 21 Book: Chapter 15)
• Lecture 24: Motion planning (Notes: Lecture 22 Book: Chapter 13 A cool visualization of configuration space for rotational robots)
• EXAM 2 (Dec 5th) (practice problems with hints)
###### Homework

You have 2 weeks for completing each homework, which should be turned in before class on the noted dates (I will collect the homework during class on the due date). Each homework should be turned in with this cover sheet. Read the academic integrity policy before you start.

Note 1: I strongly encourage you to typeset your answers (in Word, or Latex, or else). If you choose to turn in hand-written answers, write clearly enough for TAs and graders to read.

The objectives of the university’s academic advising program are to help advisees identify and achieve their academic goals, to promote their intellectual discovery, and to encourage students to take advantage of both in-and out-of class educational opportunities in order that they become self-directed learners and decision makers.

Both advisers and advisees share responsibility for making the advising relationship succeed. By encouraging their advisees to become engaged in their education, to meet their educational goals, and to develop the habit of learning, advisers assume a significant educational role. The advisee's unit of enrollment will provide each advisee with a primary academic adviser, the information needed to plan the chosen program of study, and referrals to other specialized resources.

### University Park

Jodi Vender
305 Walker Building
University Park, PA 16802
814-863-5730
[email protected]

This may not be the fastest or most sophisticated method, but I "think" it works. It is an algebraic approach to solving this type of problem. A more clever person than I can attest one way or the other.

First recognize that the slope of an equilateral triangle is $pmsqrt<3>$. From here, we can find the equation of the line that is a side of the triangle. Either one will work as whatever result we get for the number of intersection points for one side will be equal to the other. Thus, we can just double our answer.

Equation of a line $y=mx+b$, where $m=pmsqrt<3>$ (we will choose sqrt<3>$), and$b=6$. Thus, we get:$y=sqrt<3>x+6$What we are ultimately looking for is the number of intersection points between our line and the circle. The equation of a cicle is$(x-a)^2+(y-b)^2=r^2$. Where we have$a=0$,$b=1$and$r=3$. Giving us: Substitute,$y=sqrt<3>x+6$into$x^2+(y-1)^2=9$. After doing a little algebra we get: Which is a quadratic with$a=4$,$b=10sqrt<3>$and$c=16$. Using the discriminant of the quadratic: If$b^2-4ac<0$, there are no points of intersection. If$b^2-4ac=0$, the line is tangent to the circle and therefore has one point of intersection. If$b^2-4acgt 0$, there are two points of intersection. Thus, each line intersects the circle at two points giving us$4\$ total points of intersection.

## Description

Compute the distance between a point and another geometry object. At least one of the geometry objects specified must be a point.

Optional arguments available with distance are:

• geo_system : the reference ellipsoid to use for geographic coordinates. Possible values are WGS84 (the default), a common standard for Earth’s geometry, or unit_sphere , a perfect sphere of 1 meter radius.
• unit : Unit to return the distance in. Possible values are m (meter, the default), km (kilometer), mi (international mile), nm (nautical mile), ft (international foot).

If one of the objects is a polygon or a line, the point will be projected onto the line or polygon assuming a perfect sphere model before the distance is computed (using the model specified with geo_system ). As a consequence, if the polygon or line is extremely large compared to Earth’s radius and the distance is being computed with the default WGS84 model, the results of distance should be considered approximate due to the deviation between the ellipsoid and spherical models.

Example: Compute the distance between two points on the Earth in kilometers.

## This website does not support Microsoft Internet Explorer.

Two successive operations are undertaken in order to obtain a Level-1C product from Level-1B products:

• Resampling of the Level-1B image to achieve an orthiimage in TOA reflectance.
• Calculations of cloud and land/water masks for a tile in the Level-1C geometry.

### Resampling

Resampling comprises five main steps:

1. Selection of tiles intersecting the image footprint
2. Projection (geographic coding)
3. Computation of resampling grids linking the image in native geometry to the target geometry (orthoimage)
4. Resampling of each spectral band in the geometry of the orthoimage using the resampling grids and an interpolation filter
5. Computation of TOA reflectance image in the target geometry

The masks of saturated areas, no-data and technical quality are also resampled in the target geometry. The resampling can process all or some spectral bands (all by default).

#### Tiling Module

• an identifier
• a projection code (the default projection is the geographic coding, all EPSG projection shall be supported)
• an anchorage point (ground coordinates of the upper-left pixel of the tile)
• the pixel size in line and column
• the tile size in number of lines and of columns
• the tile bounding box coordinates in geographic representation

A list of tiles which intersect the footprint defined in the metadata is determined. If the intersection is void, the empty tiles are set to no-data by the resampling process.

The auxiliary data geometries are computed by this module.

#### Resampling function

The resampling function is intended to obtain radiometric information in the target geometry. This process is in two steps:

#### Geometric Transformation

The geometric transformation allows linking of the points of the target image with the points of the initial image. For SENTINEL-2, a resampling grid is used and computed for each spectral band and each detector. For each tile, there are 13 by 12 resampling grids.

Figure 1: Resampling Grid

The values of the resampling grid are computed for the footprint of the detector plus a small margin by extrapolation of the viewing directions. For each point of the orthoimage, the coordinates of the corresponding pixel in the native image are calculated by bi-linear interpolation of the four adjacent nodes. The grid computation is divided into three steps:

• Transformation of the native coordinates of the grid in coordinates expressed in the same reference system as the DEM
• Interpolation of the DEM at each grid point for obtaining the altitude
• Image location computation from each point to the source geometry of the band directly from the physical model of the band in question and detector (refined or not)

Also, the resampling grid provides complementary information:

A point on the target image can have no homologous point in the initial image. To avoid this, the initial image is projected on the target geometry to determine its footprint. Only pixels included in the interest area of the target geometry are interpolated. The footprint of two detectors within the same spectral band may also overlap. The useful area of each detector is cropped at the column defined in the GIPP inter-detector of the overlapping area for each line (the middle column by default).

Interpolation estimates the radiance values of the target point, knowing the radiance of neighbouring pixels. A linear algorithm is used for this operation with B-spline functions.

#### TOA Reflectance Computation

The numeric digital counts (CN) of each pixel image (i,j) and each spectral band (k) are converted in TOA reflectance (ρ). This conversion takes into account the equivalent extra-terrestrial solar spectrum (E s ), the incoming solar direction defined by its zenith angle (θ s ) for each pixel of the image and the absolute calibration (A k ) of the instrument MSI.

The conversion equation is:

Equation 1: Top of Atmosphere conversion

• CN k,NTDI is the equalized numeric digital count of the pixel (i,j) with NTDI, the number of SENTINEL-2 TDI lines
• E s is the equivalent extra-terrestrial solar spectrum and depends on the spectral response of the SENTINEL-2 bands
• The component d(t) is the correction for the sun-Earth distance variation (see Equation 2). It utilises the inverse square law of irradiance, under which, the intensity (or irradiance) of light radiating from a point source is inversely proportional to the square of the distance from the source.

Equation 2: Earth Sun distance

t is the Julian Day corresponding to the acquisition date (reference day: 01/01/1950).

0.01673 is the Earth orbit eccentricity.

0.0172 is the Earth angular velocity (radians/day).

The parameters A k and E s are provided by the GIPP and are also included in the ancillary data of the Level-1 products.

The sun zenith angles are determined at this level too. A sun angle grid is computed by regularly down-sampling the target geometry (Level-1C tile). The cosine of the zenith angle θ s is defined at each point of the grid using the ground coordinates and the datation of the corresponding pixel acquisition. The azimuth angle is not processed here.

Reflectance, often between 0 and 1, is converted into integer values, in order to preserve the dynamic range of the data by applying a fixed coefficient (1000 by default).

For Level-1C products, the noise model is also adapted to the new range of TOA reflectance radiometric values. The parameters (A k ,E s ) of the Level-1B noise model are corrected using Equation 1 by replacing CNk with the Level-1B parameters A k 1B and E s 1B.

The last operation to obtain the final Level-1C product is computation of the cloud masks and the land/water mask for a tile in the Level-1C geometry. The cloud mask specifies cloud type: cirrus or opaque cloud. The computation of these masks is explained and detailed in the Masks section.

Level-1B technical masks (defective, no_data pixels, etc) are then reprojected to the Level-1C geometry.

## 4. Shapefiles

Since 2007, TIGER/Line extracts from the MAF/TIGER database have been distributed in shapefile format. Esri introduced shapefiles in the early 1990s as the native digital vector data format of its ArcView software product. The shapefile format is proprietary but open its technical specifications are published and can be implemented and used freely. Largely as a result of ArcView’s popularity, shapefile has become a de facto standard for creation and interchange of vector geospatial data. The Census Bureau’s adoption of Shapefile as a distribution format is therefore consistent with its overall strategy of conformance with mainstream information technology practices.

### Elements of a Shapefile Data Set

The first thing GIS pros need to know about shapefiles is that every shapefile data set includes a minimum of three files. One of the three required files stores the geometry of the digital features as sets of vector coordinates. A second required file holds an index that, much like the index in a book, allows quick access to the spatial features and therefore speeds processing of a given operation involving a subset of features. The third required file stores attribute data in dBASE© format, one of the earliest and most widely-used digital database management system formats. All of the files that make up a Shapefile data set have the same root or prefix name, followed by a three-letter suffix or file extension. The list below shows the names of the three required files making up a shapefile data set named “counties.” Take note of the file extensions:

• counties.shp: the main shape file, containing vector coordinate data
• counties.shx: the index file
• counties.dbf: the dBASE table

Esri lists twelve additional optional files, and practitioners are able to include still others. Two of the most important optional files are the “.prj” file, which includes the coordinate system definition, and “.xml”, which stores metadata. (Why do you suppose that something as essential as a coordinate system definition is considered “optional”?)

### Try This!

In this Try This! (the second of 3 dealing with TIGER/Line Shapefiles), you will download a TIGER/Line Shapefile dataset, investigate the file structure of a typical Esri shapefile, and view it in GIS software.

You can use a free software application called Global Mapper (originally known as dlgv32 Pro) to investigate TIGER/Line shapefiles. Originally developed by the staff of the USGS Mapping Division at Rolla, Missouri as a data viewer for USGS data, Global Mapper has since been commercialized but is available in a free trial version. The instructions below will guide you through the process of installing the software and opening the TIGER/Line data.

• From the Select a layer type pick list, under Features, choose All Lines, and click submit. (You are welcome to download and investigate any TIGER/Line Shapefile(s), but we will use an All Lines dataset in the geocoding Try This later in the chapter, so your downloading one here will make you more familiar with the content.)
• From the All Lines pick list, select a state or territory, and click Submit.
• Select a County from the next pick list that appears, and click Download.
• Save the file to your computer.
The file you download should have a name like tl_2010_42027_edges.zip. The root name of this file, tl_2010_42027_edges in this example, will also be the name of the shapefile dataset. The 42027 is a federal code that represents Pennsylvania (state 42) and Centre County (county 027). The five-digit code in your file name will depend on which state and county you selected.
• The data are compressed in a .zip archive. Extract the data to a new named folder in a known location. (Within the file hierarchy that is extracted, there may be a second .zip file that needs to be uncompressed.)
2. Investigating the shapefile data set:
• Navigate to within the folder in which you stored your uncompressed TIGER/Line Shapefile dataset.
• Notice the multiple files which make up the shapefile dataset, including:
• tl_2010_42027_edges.shp, containing the vector coordinate data
• tl_2010_42027_edges.shx, the index file
• tl_2010_42027_edges.dbf, the dBASE file
• tl_2010_42027_edges.prj, containing the projection/spatial reference
• All of the files work in concert to store the necessary components of the Esri shapefile data set. You may be familiar with some of the individual files types. The contents of three of them can be easily viewed. Let's open those three. You can double click on the file and then select "from a list of installed programs,” or you may need to run the suggested application and open the file from within it.
• Open the .dbf file using Microsoft Excel.
Note the typical row-column structure of a flat-file database. Can you find the four columns, or fields, that hold the address range information? Look for LFROMADD, etc. The field name LFROMADD is shorthand for Left From Address. The 10-character length of the field name points up one of the constraints of the dBASE format -- field names are limited to 10 characters.
You should see the metadata information bracketed by tags contained within directional brackets < >. XML stands for Extensible Markup Language and is a common set of rules for encoding documents. Can you locate the portion of the document having to do with horizontal spatial accuracy? (Spatial accuracy metadata is available when you've chosen the All Lines file as your candidate shapefile.)
• Open the .prj file using Notepad, or any vanilla text editor.
There are five pieces of information in this file, separated by commas. What are they? They should reinforce some of what you learned in Chapter 2 regarding what defines a geographic coordinate system.
• The .shp and .shx files are proprietary and specific to the functionality of the shapefile data set.
• Note that one should not alter the contents of any of these files with any application other than a GIS program that is designed for that task.
3. Viewing the shapefile dataset in Global Mapper:
1. Navigate to the Blue Marble Global Mapper site.
3. Double-click on the setup file you downloaded to install the program.
4. Launch the Global Mapper program.

### Shapefile Primitives

A single shapefile data set can contain one of three types of spatial data primitives, or features – points, lines or polygons (areas). The technical specification defines these as follows:

• Points: A point consists of a pair of double-precision coordinates in the order X,Y.
• Lines: More specifically a polyline, is an ordered set of points, or vertices, that consists of one or more parts. A part is a connected sequence of two or more points. Parts may or may not be connected to one another. Parts may or may not intersect one another.
• Polygons: A polygon consists of one or more rings. A ring is a connected sequence of four or more points, or vertices, that form a closed, non-self-intersecting loop.
• Other: M (measured route data) and Z (3D vertical datum) versions of point, polyline, and polygon Shapefile data sets can be created, but are not included in the TIGER/Line Shapefile extracts.

At left in the figure above, a polygon Shapefile data set holds the Census blocks in which the edges from the MAF/TIGER database have been combined to form two distinct polygons, P1 and P2. The diagram shows the two polygons separated to emphasize the fact that what is the single E12 edge in the MAF/TIGER database (see the Figure 4.4.1 on page 4) is now present in each of the Census block polygon features.

In the middle of the illustration, above, a polyline Shapefile data set holds seven line features (L1-7) that correspond to the seven edges in the MAF/TIGER database. The directionality of the line features that represent streets corresponds to address range attributes in the associated dBASE© table. Vertices define the shape of a polygon or a line, and the Start and End Nodes from the MAF/TIGER database are now First and Last Vertices.

Finally, at right in the illustration above, a point Shapefile data set holds the three isolated nodes from the MAF/TIGER database.