有没有人有任何使用PostGIS设置Amazon Elastic Beanstalk的经验(这样我可以利用Geodjango)?
默认设置(RDS,特色MySQL)目前不支持开箱即用的功能:1.PostgreSQL + PostGIS 2.安装C/C++库(如GEOS和Proj.4)的功能
提前致谢
postgresql postgis geodjango amazon-web-services amazon-elastic-beanstalk
我正在尝试创建一个 docker 设置,以便我可以轻松构建和部署 geodjango 应用程序(带有 postgis 后端)。我有以下文件夹结构:
|-- Dockerfile
|-- Pipfile
|-- Pipfile.lock
|-- README.md
|-- app
| |-- manage.py
| |-- app
| `-- app_web
Run Code Online (Sandbox Code Playgroud)
在我设置 Django 的 Dockerfile 中,我有以下内容:
# Pull base image
FROM python:3.7
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install pipenv
COPY . /code
WORKDIR /code/
RUN pipenv install --system
# Setup GDAL
RUN apt-get update &&\
apt-get install -y binutils libproj-dev gdal-bin python-gdal python3-gdal
# set …Run Code Online (Sandbox Code Playgroud) 我有这个Django模型:
from django.contrib.gis.db import models
class Event(models.Model):
address = models.TextField()
point = models.PointField('coordinates', null=True, blank=True)
Run Code Online (Sandbox Code Playgroud)
当我使用MySQL同步此模型时,在创建索引时会打印此错误消息:
Failed to install index for events.Event model: (1252, 'All parts of a SPATIAL index must be NOT NULL')
Run Code Online (Sandbox Code Playgroud)
所以,不能使用null=True(假设我想拥有该索引),我还有其他可能性吗?我可以将点(0,0)定义为"空",但是我必须记住我计划使用数据的所有惯例,否则很多事件将发生在非洲大西洋西部的某个地方......
还有哪些其他可能性?
我正在寻找一种方法来获取一个功能集为200个国家的现有ESRI Shapefile.每个国家/地区要素都具有"NAME"属性.我的目标是创建一个Python脚本,添加一个任意(现在)的附加属性,比如"POPULATION".
当然我安装了OSGeo和GeoDjango模块.我到目前为止:
from osgeo import ogr
infile = ogr.Open('sample.shp', 1) #'sample.shp' is a pre-existing ESRI shapefile described above
inlyr = infile.GetLayerByIndex(0)
Run Code Online (Sandbox Code Playgroud)
我错过了一个OGR函数,它允许我将Feature属性字段插入现有的Shapefile中吗?
我有一个配置有GeoDjango的Django应用程序,该应用程序在CircleCI 2.0构建中失败,并出现以下错误:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library. Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
Run Code Online (Sandbox Code Playgroud)
但是,当我'django.contrib.gis'从构建中删除时DJANGO_APPS,settings.py运行成功。
除了postgres和GDAL码头工人镜像之外,是否还有其他步骤在CircleCI中配置GDAL?我(可能是错误地)假设在安装Docker映像后将找到GDAL。以下是我的config.yml:
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.3
- image: circleci/postgres:10.1-postgis
environment:
- POSTGRES_USER=ubuntu
- POSTGRES_DB=myapp_test
- image: geodata/gdal
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is …Run Code Online (Sandbox Code Playgroud) I have the following two queries. The first one works fine however the last one which uses location__dwithin returns back Unable to get repr for . Any suggestions on why the last one fails ?
querySet = modelEmployee.objects.filter(location__distance_lte=(modelemp.location, D(mi=150)))
Run Code Online (Sandbox Code Playgroud)
and the other one is:
querySet = modelEmployee.objects.filter(location__dwithin=(modelemp.location, D(mi=150)))
Run Code Online (Sandbox Code Playgroud)
This is what my modelEmployee looks like
class modelEmployee(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
title = models.CharField(max_length=200, unique=False, blank=False, null=True)
skills = models.ManyToManyField(modelSkill, blank=True)
location = models.PointField(srid=32148,max_length=40, blank=True,null=True)
objects = GeoManager() …Run Code Online (Sandbox Code Playgroud) 我想从以下点x获取坐标:yqueryset
user = User.objects.values('id', 'email', 'username', 'point').first()
Run Code Online (Sandbox Code Playgroud)
这些是我的models:
from django.db.models import Model
from django.contrib.gis.db.models import PointField
class BasePointModel(Model):
point = PointField(null=True, spatial_index=True, geography=True)
class Meta:
abstract = True
class User(AbstractUser, BasePointModel, HashableModel): # type: ignore
# First Name and Last Name do not cover name patterns
# around the globe.
name = CharField(_("Name of User"), blank=True, max_length=255)
is_online = BooleanField(_("Is online"), default=False)
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
{'id': 85270,
'email': 'username_0@email.com',
'username': 'username_0',
'point': <Point object at 0x7f8e061cc2b8>} …Run Code Online (Sandbox Code Playgroud) 我正在使用 gdal 创建一个 geodjango 容器(基于 Python alpine 官方图像)。启动容器时,出现以下错误:
>>> from django.contrib.gis import gdal
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/li...
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
Run Code Online (Sandbox Code Playgroud)
我的图像包含以下 gdal 库:
# find / -name libgdal*
/usr/lib/libgdal.so.20
/usr/lib/libgdal.so.20.5.0
/usr/lib/libgdal.a
/usr/lib/libgdal.so
Run Code Online (Sandbox Code Playgroud)
添加GDAL_LIBRARY_PATH='usr/lib/libgdal.so.20'到我的 Django 设置并没有解决这个问题。
我的 Dockerfile,基于官方的 python3 alpine 镜像。
FROM python:alpine
ENV PYTHONUNBUFFERED 1 …Run Code Online (Sandbox Code Playgroud) 几天前执行 yum upgrade 后,我的 Django 项目出现以下错误
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/joincic/GeoRouting/GeoRouting_2/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/joincic/GeoRouting/GeoRouting_2/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/joincic/GeoRouting/GeoRouting_2/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/joincic/GeoRouting/GeoRouting_2/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/joincic/GeoRouting/GeoRouting_2/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/home/joincic/GeoRouting/GeoRouting_2/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File …Run Code Online (Sandbox Code Playgroud) 我最近一直在研究 GeoDjango,我正在努力自定义管理部分中显示的 openstreet 地图的默认缩放级别。以下是我尝试过的,但没有效果,请帮助。
from django.contrib.gis import admin
class LocationAdmin(admin.OSMGeoAdmin):
default_zoom = 5
admin_site.register(ReferenceSpaceLocation, LocationAdmin)
Run Code Online (Sandbox Code Playgroud)
我的模型
class ReferenceSpaceLocation(models.Model):
geometry = models.GeometryField()
Run Code Online (Sandbox Code Playgroud)geodjango ×10
django ×8
gis ×3
postgis ×3
docker ×2
gdal ×2
postgresql ×2
python ×2
alpine-linux ×1
centos ×1
circleci ×1
django-admin ×1
dockerfile ×1
esri ×1
geospatial ×1
mysql ×1
ogr ×1
osgeo ×1
python-3.x ×1
shapefile ×1