Django model field that can hold a geoposition, and corresponding widget

Overview

django-geoposition

A model field that can hold a geoposition (latitude/longitude), and corresponding admin/form widget.

https://travis-ci.org/philippbosch/django-geoposition.svg?branch=master Join the chat at https://gitter.im/philippbosch/django-geoposition

Prerequisites

Starting with version 0.3, django-geoposition requires Django 1.8 or greater. If you need to support Django versions prior to 1.8 please use django-geoposition 0.2.3. For Django versions prior to 1.4.10 please use django-geoposition 0.1.5.

Installation

  • Use your favorite Python packaging tool to install geoposition from PyPI, e.g.:

    pip install django-geoposition
    
  • Add "geoposition" to your INSTALLED_APPS setting:

    INSTALLED_APPS = (
        # …
        "geoposition",
    )
    
  • Set your Google API key in you settings file:

    GEOPOSITION_GOOGLE_MAPS_API_KEY = 'YOUR_API_KEY'
    

    API keys may be obtained here: https://developers.google.com/maps/documentation/javascript/get-api-key

  • If you are still using Django <1.3, you are advised to install django-staticfiles for static file serving.

Usage

django-geoposition comes with a model field that makes it pretty easy to add a geoposition field to one of your models. To make use of it:

  • In your myapp/models.py:

    from django.db import models
    from geoposition.fields import GeopositionField
    
    class PointOfInterest(models.Model):
        name = models.CharField(max_length=100)
        position = GeopositionField()
    
  • This enables the following simple API:

    >>> from myapp.models import PointOfInterest
    >>> poi = PointOfInterest.objects.get(id=1)
    >>> poi.position
    Geoposition(52.522906,13.41156)
    >>> poi.position.latitude
    52.522906
    >>> poi.position.longitude
    13.41156
    

Form field and widget

Admin

If you use a GeopositionField in the admin it will automatically show a Google Maps widget with a marker at the currently stored position. You can drag and drop the marker with the mouse and the corresponding latitude and longitude fields will be updated accordingly.

It looks like this:

geoposition-widget-admin

Regular Forms

Using the map widget on a regular form outside of the admin requires just a little more work. In your template make sure that

  • jQuery is included
  • the static files (JS, CSS) of the map widget are included (just use {{ form.media }})

Example:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<form method="POST" action="">{% csrf_token %}
    {{ form.media }}
    {{ form.as_p }}
</form>

Settings

You can customize the MapOptions and MarkerOptions used to initialize the map and marker in JavaScript by defining GEOPOSITION_MAP_OPTIONS or GEOPOSITION_MARKER_OPTIONS in your settings.py.

Example:

GEOPOSITION_MAP_OPTIONS = {
    'minZoom': 3,
    'maxZoom': 15,
}

GEOPOSITION_MARKER_OPTIONS = {
    'cursor': 'move'
}

Please note that you cannot use a value like new google.maps.LatLng(52.5,13.4) for a setting like center or position because that would end up as a string in the JavaScript code and not be evaluated. Please use Lat/Lng Object Literals for that purpose, e.g. {'lat': 52.5, 'lng': 13.4}.

You can also customize the height of the displayed map widget by setting GEOPOSITION_MAP_WIDGET_HEIGHT to an integer value (default is 480).

License

MIT

User friendly Rasterio plugin to read raster datasets.

rio-tiler User friendly Rasterio plugin to read raster datasets. Documentation: https://cogeotiff.github.io/rio-tiler/ Source Code: https://github.com

372 Dec 23, 2022
Blender addons to make the bridge between Blender and geographic data

Blender GIS Blender minimal version : 2.8 Mac users warning : currently the addon does not work on Mac with Blender 2.80 to 2.82. Please do not report

5.9k Jan 02, 2023
gpdvega is a bridge between GeoPandas and Altair that allows to seamlessly chart geospatial data

gpdvega gpdvega is a bridge between GeoPandas a geospatial extension of Pandas and the declarative statistical visualization library Altair, which all

Ilia Timofeev 49 Jul 25, 2022
Use Mapbox GL JS to visualize data in a Python Jupyter notebook

Location Data Visualization library for Jupyter Notebooks Library documentation at https://mapbox-mapboxgl-jupyter.readthedocs-hosted.com/en/latest/.

Mapbox 620 Dec 15, 2022
Earthengine-py-notebooks - A collection of 360+ Jupyter Python notebook examples for using Google Earth Engine with interactive mapping

earthengine-py-notebooks A collection of 360+ Jupyter Python notebook examples for using Google Earth Engine with interactive mapping Contact: Qiushen

Qiusheng Wu 1.1k Dec 29, 2022
Manipulation and analysis of geometric objects

Shapely Manipulation and analysis of geometric objects in the Cartesian plane. Shapely is a BSD-licensed Python package for manipulation and analysis

3.1k Jan 03, 2023
This app displays interesting statistical weather records and trends which can be used in climate related research including study of global warming.

This app displays interesting statistical weather records and trends which can be used in climate related research including study of global warming.

0 Dec 27, 2021
Bacon - Band-limited Coordinate Networks for Multiscale Scene Representation

BACON: Band-limited Coordinate Networks for Multiscale Scene Representation Project Page | Video | Paper Official PyTorch implementation of BACON. BAC

Stanford Computational Imaging Lab 144 Dec 29, 2022
ColoringMapAlgorithm-CSP- - Graphical Coloring of Countries with Condition Satisfaction Algorithm

ColoringMapAlgorithm-CSP- Condition Satisfaction Algorithm Output Condition

Kerem TAN 2 Jan 10, 2022
A public data repository for datasets created from TransLink GTFS data.

TransLink Spatial Data What: TransLink is the statutory public transit authority for the Metro Vancouver region. This GitHub repository is a collectio

Henry Tang 3 Jan 14, 2022
Yet Another Time Series Model

Yet Another Timeseries Model (YATSM) master v0.6.x-maintenance Build Coverage Docs DOI | About Yet Another Timeseries Model (YATSM) is a Python packag

Chris Holden 60 Sep 13, 2022
WhiteboxTools Python Frontend

whitebox-python Important Note This repository is related to the WhiteboxTools Python Frontend only. You can report issues to this repo if you have pr

Qiusheng Wu 304 Dec 15, 2022
Program that shows all the details of the given IP address. Build with Python and ipinfo.io API

ip-details This is a program that shows all the details of the given IP address. Build with Python and ipinfo.io API Usage To use this program, run th

4 Mar 01, 2022
Construct and use map tile grids in different projection.

Morecantile +-------------+-------------+ ymax | | | | x: 0 | x: 1 | | y: 0 | y: 0

Development Seed 67 Dec 23, 2022
:earth_asia: Python Geocoder

Python Geocoder Simple and consistent geocoding library written in Python. Table of content Overview A glimpse at the API Forward Multiple results Rev

Denis 1.5k Jan 02, 2023
Helping data scientists better understand their datasets and models in text classification. With love from ServiceNow.

Azimuth, an open-source dataset and error analysis tool for text classification, with love from ServiceNow. Overview Azimuth is an open source applica

ServiceNow 145 Dec 23, 2022
Replace MSFS2020's bing map to google map

English verison here 中文 免责声明 本教程提到的方法仅用于研究和学习用途。我不对使用、拓展该教程及方法所造成的任何法律责任和损失负责。 背景 微软模拟飞行2020的地景使用了Bing的卫星地图,然而卫星地图比较老旧,很多地区都是几年前的图设置直接是没有的。这种现象在全球不同地区

hesicong 272 Dec 24, 2022
This is the antenna performance plotted from tinyGS reception data.

tinyGS-antenna-map This is the antenna performance plotted from tinyGS reception data. See their repository. The code produces a plot that provides Az

Martin J. Levy 14 Aug 21, 2022
Imports VZD (Latvian State Land Service) open data into postgis enabled database

Python script main.py downloads and imports Latvian addresses into PostgreSQL database. Data contains parishes, counties, cities, towns, and streets.

Kaspars Foigts 7 Oct 26, 2022
A toolbox for processing earth observation data with Python.

eo-box eobox is a Python package with a small collection of tools for working with Remote Sensing / Earth Observation data. Package Overview So far, t

13 Jan 06, 2022