For GIS analysis in R I recommend the sf package. One of the great advantages of this package is that, once you loaded a file into your enviroment with read_sf(), you can manipulate your data using the regular data.frame methods commonly used in R.
# read your data into your environment, make sure your data is stored in your working directory
meow <- ...
As an addition to the solution above (@babel): you can do it also only with the field calculator, without doing the intersection with the processing tools. The expression is something like this one to get the area for the blue ones:
area(intersection($geometry,aggregate('orange','collect', $geometry, intersects($geometry, geometry(@parent)))))
Use Menu Vector / Geoprocessing tools / Intersection, set the two polygon layers you use (named orange and blue in my case) as input and you get the intersecting area (outlined in red on the screenshot) as a output in a new polygon layer intersection. On this layer, open field calculator to calculate the area using either area ($geometry) or $area.
It may be a wrong assumption that WKT and WKB are identical. Computing with floating point numbers is inaccurate.
Here is a test made with PostGIS
'POLYGON ((-45.70072144031528 70.79588950876575,-45.70072144031528 -32.671894242015554,202.6781848096847 -32.671894242015554,202.6781848096847 70.79588950876575,-45....
One solution is to basically take the difference between the multipoints and the resulting intersection between the multipoints and the polygon, i.e.: multipoints.difference(multipoints.intersection(polygon))
Here is a piece of commented code for understanding:
import matplotlib.pyplot as plt
from shapely.geometry import Polygon, MultiPoint
import geopandas ...
I think I figured it out. I just hadn't done a spatial join with SQL until now.
I ended up doing the spatial join on a line FC instead of a point FC (but I convert the lines to midpoints in the subquery).
--Spatial join between line midpoints and and a polygon FC.
--Returns the zone ID from the intersecting polygon.
Example code below.
Firstly, join the end point of the first curve with end of second curve, then join the start point of the second curve with start point of the first point. ...
If you have a point layer and a line layer, then you can count the lines near by the points using field calculator:
Open the attribute table of point layer
Open the field calculator dialog (abacus icon)
Enter the following expression
aggregate( layer:='line', aggregate:='count', expression:="ATTR",filter:= intersects( buffer(geometry(@parent)...
I think the issue is the you buffer the locations while using the EPSG 4326 projection. This doesn't use meters as the unit so the buffer zones might not all be 2km.
Here I re-project the data to the WGS 84 / Pseudo-Mercator projection. Depending on where you're points are located there might be a more suitable projection also.
locations = [[54.156014, 53....
I bumped in to same problem. Then I found https://gis.stackexchange.com/a/243490/173422 and realized with Intersects-filter, there is a requirement of ValueReference (see: https://docs.geoserver.org/stable/en/user/filter/filter_reference.html).
Example, the GeoServer I'm working with will return geometry in WFS-response field <geom> and I need to match ...
Reproject to a projected coordinate system in meters, for example EPSG:32634. Then the buffer distance will be in meters:
import geopandas as gpd
import pandas as pd
events = pd.DataFrame([