django-rest-framework-gis | GeoDjango tools for Django Rest Framework | REST library
kandi X-RAY | django-rest-framework-gis Summary
kandi X-RAY | django-rest-framework-gis Summary
GeoDjango tools for Django Rest Framework
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Construct a geometry object from a string representation .
- Parses a GeoJSON response into a GeoJSON feature .
- Create a feature object from the data .
- Get package data .
- Render feature collection .
- Return a list of all python packages in the given package .
- Get the version of the given package .
- Convert geosge to GeoJSON .
- Convert obj to representation
django-rest-framework-gis Key Features
django-rest-framework-gis Examples and Code Snippets
Community Discussions
Trending Discussions on django-rest-framework-gis
QUESTION
I'm building an API using DJANGO-REST-FRAMEWORK. I'm trying to filter the back end using parameters passed to the body of the request, this is my set up:
views.py
...ANSWER
Answered 2020-Aug-28 at 06:42In your urls.py, you have configured something wrong:
QUESTION
I am trying to serialize into geojson a model with a foreign key that has a geometry field. I am using the django-rest-framework-gis. I am using django 2.2
I'm stuck on this and none of the other related answers on Stack Overflow work for me. e.g. I have tried versions of this:
- How can I flatten a foreignkey object with django-rest-framework-(gis)
- Set serializer geo_field as PointField from another model - Django
The problem is I get this error:
Expected a Response
, HttpResponse
or HttpStreamingResponse
to be returned from the view, but received a
Models:
...ANSWER
Answered 2020-Apr-15 at 23:50Serializer is waiting for data from you. I got the same error when I tried your view with a simple modeling. I think there is something wrong with the definition. can you try the presentation:
QUESTION
I'm developing a GeoDjango app which use the provided WorldBorder model in the tutorial. I also created my own Region model which is tied to WorldBorder. So a WorldBorder/Country can have multiple Regions which has borders (MultiPolygon field) in it too.
I made the API for it using DRF but it's so slow, it takes 16 seconds to load all WorldBorder and Regions in GeoJSON format. The returned JSON size is 10MB though. Is that reasonable?
I even change the serializer to serpy which is way much faster than the DRF GIS serializer but only offers 10% performance improvement.
Turns out after profiling, most of the time is spent in the GIS functions to convert data type in the database to list of coordinates instead of WKT. If I use WKT, the serialization is much faster (1.7s compared to 11.7s, the WKT is only for WorldBorder MultiPolygon, everything else is still in GeoJson)
I also tried to compress the MultiPolygon using ST_SimplifyVW with low tolerance (0.005) to preserve the accuracies, which brings down the JSON size to 1.7 MB. This makes the total load to 3.5s. Of course I can still find which is the best tolerance to balance accuracy and speed.
Below is the profiling data (the sudden increase of queries in the simplified MultiPolygon is due to bad usage of Django QS API to get use of ST_SimplifyVW)
EDIT: I fixed the DB query so the query calls stays the same at 75 queries and as expected, it does not increase the performance significantly.
EDIT: I continued to improve my DB queries. I reduced it to just 8 queries now. As expected, it does not improve that much performance.
Below is profiling for the function calls. I highlight the part which took most of the time. This one is using vanilla DRF GIS implementation.
Below is when I use WKT for one of the MultiPolygon field without ST_SimplifyVW.
Here's the models as requested by @Udi
...ANSWER
Answered 2018-Jan-01 at 20:08Since your geographic data does not change frequently, try caching all region/country polygons in pre-calculated geojsons. I.e., create a /country/123.geojson
API call or static file with the geo data for all regions in this country, probably simplified in advance.
Your other API calls should return only the numeric data, without geographic polygons, leaving the combining task to the client.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-rest-framework-gis
You can use django-rest-framework-gis like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page