A script that takes the path to a shapefile as a command line argument. This shapefile is then converted to a shapefile that has latitude and longitude as the projection.
- fiona
- shapely
- pyproj
Create python environment with pyproj 1.9.6 (and proj 5.2). | |
Create a different python environment with pyproj 2.2.0 (and proj 6.1.0) | |
Download (for now) the zipfile at http://pmarshwx.com/tmp/usa.zip which is a folder of a shapefile | |
Run the test.py script (below) with the unzipped file (which is a folder) from above in same directory as the python script in each environment | |
My results on a MBP (ballparks after running multiple times): | |
pyproj=1.9.6 (proj=5.2.0) vs pyproj=2.2.1 (proj=6.1.0) | |
read USbounds shpfile: 0.015 seconds vs 0.015 seconds |
import numpy as np | |
def parse(lines, mask=-9999.): | |
''' | |
A simple routine to parse the output of GEMPAK's GDLIST output. | |
Parameters | |
---------- | |
lines : string, sequence |
om,yr,mo,dy,date,time,zone,state,stf,stn,f,inj,fat,dam,closs,slat,slon,elat,elon,len,wid,nstate,stno,sg | |
1,1950,1,3,1/3/50,11:00:00,3,MO,29,1,3,3,0,6,0,38.77,-90.22,38.83,-90.03,9.5,150,2,0,1 | |
2,1950,1,3,1/3/50,11:55:00,3,IL,17,2,3,3,0,5,0,39.1,-89.3,39.12,-89.23,3.6,130,1,1,1 | |
3,1950,1,3,1/3/50,16:00:00,3,OH,39,1,1,1,0,4,0,40.88,-84.58,0,0,0.1,10,1,1,1 | |
4,1950,1,13,1/13/50,5:25:00,3,AR,5,1,3,1,1,3,0,34.4,-94.37,0,0,0.6,17,1,1,1 | |
5,1950,1,25,1/25/50,19:30:00,3,MO,29,2,2,5,0,5,0,37.6,-90.68,37.63,-90.65,2.3,300,1,1,1 | |
6,1950,1,25,1/25/50,21:00:00,3,IL,17,3,2,0,0,5,0,41.17,-87.33,0,0,0.1,100,1,1,1 | |
7,1950,1,26,1/26/50,18:00:00,3,TX,48,1,2,2,0,0,0,26.88,-98.12,26.88,-98.05,4.7,133,1,1,1 | |
8,1950,2,11,2/11/50,13:10:00,3,TX,48,2,2,0,0,4,0,29.42,-95.25,29.52,-95.13,9.9,400,1,1,1 | |
9,1950,2,11,2/11/50,13:50:00,3,TX,48,3,3,12,1,4,0,29.67,-95.05,29.83,-95,12,1000,1,1,1 |
Grid file: /NAWIPS/nadata2/model/sfcOA/sfcoaruc_13062120 | |
GRID IDENTIFIER: | |
TIME1 TIME2 LEVL1 LEVL2 VCORD PARM | |
130621/2000 0 NONE M1CP | |
AREA: DSET GRID SIZE: 151 113 | |
COLUMNS: 1 151 ROWS: 1 113 | |
Scale factor: 10** 0 |
cimport cython | |
import numpy as np | |
cimport numpy as np | |
cdef extern from 'math.h': | |
float exp(float x) | |
float cos(float x) | |
float sin(float x) | |
float fabs(float x) |