What could be causing my sjoin() function to produce an empty GeoDataFrame?

I'm currently working on a spatial join operation between two GeoDataFrames.

The first GeoDataFrame contains the coordinates of points associated with specific names. The second GeoDataFrame consists of polygons derived from the French cadastre data.

My goal is to merge the two datasets based on their geographic relationships.

With an inner join, I expect to retrieve the names Melynn and Gaspard because they have coordinates that fall within the polygon boundaries.

Note: Both GeoDataFrames share the same crs: "EPSG:2154"

Details of the first GeoDataFrame :

data{'Noms (z)'['Melynn','Paul','David','Gaspard'],'lat'[49.46138,49.4404591,49.4404591, 49.46138], 'long':[1.07948,1.0939658,1.0939658, 1.07948]}

df=pd.DataFrame(data)

pts=gpd.GeoDataFrame(df,geometry=gpd.points_from_xy(df['lat'],df['long'],crs="EPSG:2154"))

Information about the second GeoDataFrame :

shapes = gpd.read_file("..\Data sets\cadastre-76-sections-shp\sections.shp")

subshapes = shapes[shapes['commune']=='76451']

The merge process :

gpd.sjoin(pts, subshapes, how="inner", op="within")

Despite using the inner join method, I am only getting an empty GeoDataFrame as output...

Answer №1

Upon waking up refreshed, it dawned on me that the coordinates were actually in WGS84 (EPSG:4326) format, which explained why I had inputted them incorrectly.

After adjusting the coordinates accordingly, everything functioned smoothly as expected.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Modifying data within a werkzeug request object

Upon receiving a werkzeug request object, I encountered the challenge of needing to alter a value within this immutable object. Recognizing the intended immutability of werkzeug request objects, I am faced with the dilemma of finding a solution to change a ...

Struggling to set up win32api library in Python

Recently, I encountered an issue while attempting to execute a Python code. The error message that popped up was: No module named win32api In my attempt to resolve this issue, I proceeded to install the package using the command pip install pywin32. Howe ...

Exploring Python capabilities on both Windows 7 and Windows 10 operating systems

Struggling with running Python on my laptop lately. Originally had Windows 8.1, but noticed that most of my peers were using Python with Windows 10. Decided to upgrade to Windows 10, but still encountering issues. Surprisingly, when I switched back to my ...

Executing a Python script asynchronously from a Node.js environment

I am currently managing a node.js program that handles approximately 50 different python script instances. My goal is to implement a throttling mechanism where only 4 processes can run in parallel at any given time. Initially, I attempted to create a simp ...

Troubleshooting "TypeError" in the statsmodels Holt and Holt-Winters function for Python: A comprehensive guide

My approach involves utilizing data in the following format: data = [253993,275396.2,315229.5,356949.6,400158.2,442431.7,495102.9,570164.8,\ 640993.1,704250.4,767455.4,781807.8,776332.3,794161.7,834177.7,931651.5,\ 1028390,1114914] Subsequently ...

Splitting arrays at their edges

Query: Given an ndarray: In [2]: a Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) I am searching for a method that would result in: array([7, 8, 9, 0, 1]) Example: Starting at index 8, crossing the array boundary and stopping at index 2 (included). When ...

Converting multi-dimensional arrays into Pandas data frame columns

Working with a multi-dimensional array, I need to add it as a new column in a DataFrame. import pandas as pd import numpy as np x = np.array([[1, 2, 3], [4, 5, 6]], np.int32) df = pd.DataFrame(['A', 'B'], columns=['First']) ...

Approaches for transforming data and displaying the output in HTML using Django

My data is structured as follows: ws=[{'a': datetime.date(2020, 8, 31), 'b': <BB: 01>, 'c': <CC: 4>}, {'a': datetime.date(2020, 8, 31), 'b': <BB: 01>, 'c': <CC: 5>}, ...

The Corona Simulator ceased to function properly once it established a connection with the server

Having an issue with two server files when working with the Corona simulator. One file is functioning properly while the other isn't. I am struggling to identify the difference between these two files. Below is the code for both servers: Non-working ...

The structure of Django, NPM, and Node packages

When considering the architecture of the project I will be working on, it's important to note the structure of the node_packages: |- Django project |-- app1 |-- app2 |-- node_modules |--- foundation-sites |--- grunt |-- static |--- css |--- images | ...

Geopandas taps into its creative side when it comes across a missing street

While working with Geopandas, I have observed a curious behavior. When Geopandas is given a street address that it cannot locate, it somehow substitutes an existing street that appears to be close to the city of the original address. Below is an example of ...

Tensorflow 2.13.0 Error: Module Not Found - Unable to Locate 'tensorflow.keras'

Encountered the mentioned issue while coding in Spyder using Anaconda. It seems to have occurred when opening a new file in an environment where I had already created and saved a tf Keras model, and then trying to fetch it in that new file. Despite attemp ...

"Utilize URL parameters to specify a date range when working with Django Rest

In my JSON structure, I have data entries with timestamps and names: [ { "date": "2017-12-17 06:26:53", "name": "ab", }, { "date": "2017-12-20 03:26:53", "name": "ab" }, { "date": "2017-12- ...

Adding quotation marks to the string form of a two-dimensional array in Python

My code takes user input from a text box and needs to convert it into a 2D list of strings. The user input comes from a Jupyter Dash text input I am working on creating a design where the user does not have to quote the elements themselves and can simply ...

Is it possible to alter the color by simply clicking on three Canvas circles using the same mouse button?

How can I modify the structure to recolor the circle when clicked with the mouse? import tkinter as tk class CanvasEvents(tk.Tk): def __init__(self): super().__init__() self.geometry('510x510+700+100') self.title(&quo ...

Matching a string with a generic date in the middle using Python

Seeking advice on how to match a string (filename) with any date format in the middle. For example, python-1u222-ea-str-b08-10_dec_2018.zip. I am attempting to find the Pythonic way to match this string with any date instead of 10_dec_2018. element = "py ...

Discover how to extract JSON data from a webpage even when the response is "None"

I need to retrieve data maps from their API, which are in JSON format. This is the code I have written: r = requests.get(url) if r.ok: soup = BeautifulSoup(r.content, 'lxml') soup.status_code j = json.loads(str(soup)) However, an e ...

Python script to extract comments from numerous zip files

I recently delved into the world of Python and now face a challenge that entails rifling through thousands of zip files to uncover crucial clues hidden in their comments. The aspect causing me great difficulty is the extraction of these elusive comments. ...

What is the process to extract a data list from a frame, access and click on a link within the frame, and then proceed to click on another link within

I have uploaded a screenshot for your reference. I successfully logged into the website, but I am unable to navigate to a specific link and click on it. Here are the steps I need to perform: Retrieve the list of stocks from the frame and save it Select a ...

Python and Selenium: Techniques for handling new window pop-ups

When I click a button with Twitter, a new window opens after a few seconds. Is there a way to wait for it without using a bad method? Ui.click_el(link.W9FormNodes.TWITTER_BUTTON) # Wait for new window and switch to it time.sleep(3) aw = dr ...