I wrote a function that takes dxfgeometry and coordinate points and converts them to the geoJSON. But it was not showing the location which it was supposed to show.
Can you provide me a way and mathematical calculations to create a geojson file?
I wrote a function that takes dxfgeometry and coordinate points and converts them to the geoJSON. But it was not showing the location which it was supposed to show.
Can you provide me a way and mathematical calculations to create a geojson file?
Copyright © 2021 Jogjafile Inc.
According to the documentation, you could try doing it like this:
First get epsg code and the CRS transformation matrix:
Query the DXF entities to export:
Create a GeoProxy object from the DXF entity:
Transform DXF WCS coordinates in modelspace units into the CRS coordinate system by the transformation matrix m:
The next step assumes a EPSG:3395 projection, everything else needs a custom transformation function:
Use the json module from the Python standard library to write the GeoJSON data, provided by the GeoProxy.geo_interface property:
The content of the GeoJSON file looks like this: