New answers tagged point-in-polygon
This does not seem to be an issue with the function. From the R code, included in your zip file, it looks like there was some confusion in your naming convention that caused a syntax error by calling the wrong objects in tapply. You were also attempting the add the tapply results to the points and not to the source polygon object, which the values were ...
Your guess is correct - use 'Count Unique Points in Polygon' in the processing toolbox, using "car_id" as the "Class field".
If you imported osm file into a data base then you can use this Query: SELECT distinct polygon.name,line.name FROM planet_osm_line AS line CROSS JOIN planet_osm_polygon AS polygon WHERE polygon.admin_level = '8' AND ST_Contains(polygon.way, line.way) AND line.highway in ('primary', 'secondary', 'tertiary', 'road', 'residential','motorway', 'trunk', ...
whether a point [(x,y)] lies within a polygon [(x,y), (x,y), (x,y), (x,y)] but the code fails if the point lies on a boundary or a vertex You need to understand the topologic rules: From Quirks of the "Contains" Spatial Predicate Polygons do not contain their boundary (Geometry A contains Geometry B if no points of B lie in the exterior of A, ...
You should use the function 'over' of the sp package to check if one lat long pair is inside or not a polygon.
You should show what you have tried in some sort of workflow, ideally with example data. Anyway, you are making things too complicated, I think. I would suggest looking at raster::extract, raster::rasterize to work with the polygons and raster data. If you want to work with the point data derived from the raster data, you can use sp::over or raster::extract
I recently needed to do something similar. I had around 70,000 polygons, and around ~40 million points to place. With that in mind, a few things about the particulars of my answer: it needs to be fast. nothing else is relevant to the placement of the point other than the polygon ID. none of the polygons I am working with are nested inside any signle ...
Maybe try var feature = e.target.feature instead of e.layer.feature? e.layer would probably be the entire featureLayer, not the individual clicked feature. Hence it would not have the feature property defined, hence your error message when trying to access feature.properties.
I got it working by entering this query: CREATE TABLE my_table AS SELECT buffer1.id, COUNT(facility1) as bf1 FROM buffer1 LEFT JOIN facility1 ON ST_CONTAINS(buffer1.st_buffer,facility.geom) GROUP BY buffer1.id NATURAL JOIN SELECT buffer2.id, COUNT(facility1) as bf2 FROM buffer2 LEFT JOIN facility1 ON ST_CONTAINS(buffer2.st_buffer,facility.geom) GROUP BY ...
Top 50 recent answers are included