Skip to content

Conversation

@koperagen
Copy link
Collaborator

fixes #1565

@koperagen koperagen added this to the 1.0.0-Beta5 milestone Dec 15, 2025
@koperagen koperagen self-assigned this Dec 15, 2025
@koperagen koperagen added the geo Anything related to the GeoDataFrame label Dec 15, 2025
simplePointsGeoDf.writeGeoJson(tempFile)

assertEquals(simplePointsGeoDf, GeoDataFrame.readGeoJson(tempFile.toURI().toURL()))
val loadedGeoDataFrame = GeoDataFrame.readGeoJson(tempFile.toURI().toURL())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add more IO overloads ;)

assertEquals(simplePointsGeoDf, GeoDataFrame.readGeoJson(tempFile.toURI().toURL()))
val loadedGeoDataFrame = GeoDataFrame.readGeoJson(tempFile.toURI().toURL())
assertEquals(simplePointsGeoDf.df, loadedGeoDataFrame.df)
// TODO: Doesn't work because of how equality between CRS is checked by geotools
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper way to check CRS equality in Geotools is
CRS.equals, or CRS.equalsIgnoreMetadata if you don't want to compare metedata.

But there, shouldn't they be equal?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't help :(
println(CRS.equalsIgnoreMetadata(simplePointsGeoDf.crs, loadedGeoDataFrame.crs))

false

They are in fact identical, two lines just go in different order
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, then there's problem here! In GeoDataFrame (as in GeoJson specification) longitude should always go first! That's important!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. This is how CRS looks right after reading of features:
image

Order of longitude is broken?
image

Content of the file we're reading from:
"crs":{"type":"name","properties":{"name":"EPSG:4326"}}

I see that our default CRS is created with longitudeFirst = true: CRS.decode("EPSG:4326", true)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

geo Anything related to the GeoDataFrame

Projects

None yet

Development

Successfully merging this pull request may close these issues.

writeGeoJson breaks ordering of rows:

2 participants