Skip to content

Instantly share code, notes, and snippets.

@pigreco
Last active September 27, 2018 15:18
Show Gist options
  • Save pigreco/75ae641a5ecd455e77c9bd9593b35920 to your computer and use it in GitHub Desktop.
Save pigreco/75ae641a5ecd455e77c9bd9593b35920 to your computer and use it in GitHub Desktop.
test velocità
time[secs] programma dataset PC Piattaforma
52 QGIS DEV 3.3 sqlite + spatialindex 1M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
206 QGIS DEV 3.3 sqlite + spatialindex 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
93 QGIS 3.2.3 sqlite + spatialindex 1M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
352 QGIS 3.2.3 sqlite + spatialindex 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
87 QGIS 2.18.24 sqlite + spatialindex 1M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
311 QGIS 2.18.24 sqlite + spatialindex 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
61 SpatiaLite_GUI 2.10 sqlite + spatialindex 1M points AMD 2.10 Ghz 8 gb RAM Win 10 64b
72 SpatiaLite_GUI 2.10 sqlite + spatialindex 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b
562 QGIS DEV 3.3 GPKG 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
220 QGIS DEV 3.3 GPKG + spatialindex 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b OSGeo4W
12 pgadmin3 postgis + spatialindex 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b
97 mapshaper shp riga comando linux 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b
24 R Studio GPKG 5M points AMD 2.10 Ghz 8 gb RAM Win 10 64b
@pigreco
Copy link
Author

pigreco commented Sep 26, 2018

Mapshaper - https://mapshaper.org/

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo npm install -g mapshaper

image

time node  --max-old-space-size=4192 `which mapshaper` reticolo.shp  -join vertici.shp  calc='join_count = count()' fields= -o out.shp

wiki

output

pk count
1 355791
2 662172
3 852466
4 857193
5 1126114
6 1321607

@pigreco
Copy link
Author

pigreco commented Sep 26, 2018

PostGIS -https://postgis.net/

image

select r.id as rowid, count(*) as nro
from reticolo r, vertici p
where st_contains(r.geom, p.geom)  
group by 1
order by 1

@pigreco
Copy link
Author

pigreco commented Sep 26, 2018

R + RStudio - https://www.r-project.org/

library(rgdal)
library(GISTools)
setwd("F:\\aiuti_QGIS\\dottorando")

layers <- ogrListLayers("dati.gpkg")

punti<-readOGR("dati.gpkg", layers[1])
reticolo<-readOGR("dati.gpkg", layers[2])
#### calcolo conteggio ########
conteggio<-poly.counts(punti, reticolo)

#### calcolo conteggio con misura tempo esecuzione #######
start.time <- Sys.time()
conteggio<-poly.counts(punti, reticolo)
end.time <- Sys.time()
time.taken <- end.time - start.time
time.taken

image

Output

image

@pigreco
Copy link
Author

pigreco commented Sep 26, 2018

QGIS 3.3 dev - https://qgis.org/it/site/

utilizzando le tabelle in postgresql/postgis con spatialindex

image

@pigreco
Copy link
Author

pigreco commented Sep 27, 2018

QGIS 2.18.24 DBmanager - PostgreSQL/PostGIS

select r.id as rowid, count(*) as nro
from reticolo r, vertici p
where st_contains(r.geom, p.geom)  
group by 1
order by 1

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment