PostGIS

GIS: partition area based on equal population

陌路散爱 提交于 2020-01-01 06:54:12
问题 I want to partition a US state into 20 parts of approximately equal population. I can do this using, say, tracts, ZIP codes or another smaller geography. I'm looking for an algorithm to do the partitioning. It can be in any language or software (ArcGIS, QGIS, python, PostGIS, R, node). For grouping or clustering algorithms I've looked at like k-means, ArcGIS Grouping Analysis, etc. These do not seem to do what's needed, since they group based on the similarity of a variable don't partition

Creating an extension test in postgresql

时光总嘲笑我的痴心妄想 提交于 2020-01-01 03:36:09
问题 I want to create an extension test in postgres (Using PostGis), so I want to do the following steps: 1.- Edit the file btree_interval.c from btree_gist in this way: gbt_intvkey_cmp(const void *a, const void *b) { intvKEY *ia = (intvKEY *) (((const Nsrt *) a)->t); intvKEY *ib = (intvKEY *) (((const Nsrt *) b)->t); int res; ...... ...... printf("Test for PostGis\n"); return res; } Only add a printf , because I just want to do a little test 2.- Run the following command: gcc -shared -o btree

django error on migration: "There is no unique constraint matching given keys for referenced table

三世轮回 提交于 2019-12-31 04:13:06
问题 So I have seen that a lot of these kinds of questions have popped up (few answered) and none in a Django aspect that I saw. I am confused why I am getting the error, I am guessing i am missing something on my field decorator or what not in my model definition. Here are the two models... (one abbreviated). I thought I did everything right with unique and primary key set to true in the one table that the foreign key gives reference to but upon migrate I get this error: django.db.utils

How to update table when view is updated?

倖福魔咒の 提交于 2019-12-31 02:53:13
问题 I want to update table when her view is updated. I use postgresql/postgis. I create view. CREATE VIEW filedata_view AS SELECT num, id, ST_TRANSFORM(the_geom,900913) FROM filedata And now when its updated i want to update TABLE with this data. But i heared that triggers cant be puted in VIEW. So how to do this? Now i use this function CREATE OR REPLACE FUNCTION update_table() RETURNS TRIGGER AS ' BEGIN UPDATE filedata SET id=NEW.id, the_geom=ST_TRANSFORM(NEW.st_transform,70066) where num=NEW

Querying json in postgres

南笙酒味 提交于 2019-12-31 01:48:36
问题 I have to extract data from a json file who contains spatial information. The content of this file is {"vertices":[{"lat":46.744628268759314,"lon":6.569952920654968}, {"lat":46.74441692818192,"lon":6.570487107359068}, {"lat":46.74426116111054,"lon":6.570355867853787}, {"lat":46.74447250168793,"lon":6.569821681149689}], "name":"demo-field", "cropType":"sugarbeet", "cropPlantDistance":0.18000000715255737, "rowDistance":0.5,"numberOfRows":[28,12,12],"seedingDate":"2016-08-17T07:39+00:00"} I've

How to create a circle in meters in postgis?

假装没事ソ 提交于 2019-12-30 06:37:21
问题 I would like to ask how to create a circle with radius=4km . I have tried the ST_Buffer function but it creates a larger circle. (I see the created circle by inserting its polygon into an new kml file.) This is what i am trying. INSERT INTO camera(geom_circle) VALUES(geometry(ST_Buffer(georgaphy(ST_GeomFromText('POINT(21.304116745663165 38.68607570952619)')), 4000))) The center of the circle is a lon lat point but I don't know its SRID because I have imported it from a kml file. Do I need the

Configuring Amazon Elastic Beanstalk with PostGIS

↘锁芯ラ 提交于 2019-12-30 06:29:09
问题 Does anyone have any experience setting up Amazon Elastic Beanstalk with PostGIS (so that I can take advantage of Geodjango)? There are a number of features that the default setup (RDS, featuring MySQL) does not currently support out of box: 1. PostgreSQL + PostGIS 2. The ability to install C/C++ libraries such as GEOS and Proj.4 Thanks in advance 回答1: If you want to use geodjango with Amazon Elastic Beanstalk you need to create a custom AMI where you can install PostGIS and then point your

Configuring Amazon Elastic Beanstalk with PostGIS

回眸只為那壹抹淺笑 提交于 2019-12-30 06:29:05
问题 Does anyone have any experience setting up Amazon Elastic Beanstalk with PostGIS (so that I can take advantage of Geodjango)? There are a number of features that the default setup (RDS, featuring MySQL) does not currently support out of box: 1. PostgreSQL + PostGIS 2. The ability to install C/C++ libraries such as GEOS and Proj.4 Thanks in advance 回答1: If you want to use geodjango with Amazon Elastic Beanstalk you need to create a custom AMI where you can install PostGIS and then point your

Find the nearest points along the linestring in specified distance limit and order

北战南征 提交于 2019-12-30 03:12:20
问题 I have such problem and I would be nice If somebody can help me. I have points table with GIST index. Those points don't change in time. I would like to fetch points that are near some given linestring. Example: Imagine that linestring is the road and points are poi along the road. I would like to fetch poi's that are in 5 km distance from the given road. I would like to fetch those pois in correct order (driving order along the road). Look at the image: For given road from point 1 to 5 i

How to intelligently degrade or smooth GIS data (simplifying polygons)?

Deadly 提交于 2019-12-28 07:40:07
问题 I have detailed US county maps, from the TIGER LINE data sets. How might I sample, smooth, or degrade the data so that I get straighter, more boxy, less "noisy" shapes to represent the geographical features -- in this case just county boundaries and state lines, but maybe also in the general case? The sampling could happen at rendering time if that can be done efficiently, or a parallel data set could be generated and stored. I am using PostGIS, and the lines are multi-polylines generated by