Hex Artifact Content
Not logged in

Artifact d1f953cf63330714941fe06556b55e00996f8cd1:

Wiki page [ZippedSHP] by sandro 2020-05-07 15:52:09.
0000: 44 20 32 30 32 30 2d 30 35 2d 30 37 54 31 35 3a  D 2020-05-07T15:
0010: 35 32 3a 30 39 2e 33 35 39 0a 4c 20 5a 69 70 70  52:09.359.L Zipp
0020: 65 64 53 48 50 0a 50 20 39 32 65 33 30 37 36 31  edSHP.P 92e30761
0030: 39 63 35 66 34 35 38 62 65 38 38 64 63 30 61 37  9c5f458be88dc0a7
0040: 64 62 38 37 31 62 65 38 31 61 30 39 65 36 32 64  db871be81a09e62d
0050: 0a 55 20 73 61 6e 64 72 6f 0a 57 20 31 39 31 32  .U sandro.W 1912
0060: 0a 42 61 63 6b 20 74 6f 20 3c 61 20 68 72 65 66  .Back to <a href
0070: 3d 22 68 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61  ="https://www.ga
0080: 69 61 2d 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c  ia-gis.it/fossil
0090: 2f 6c 69 62 73 70 61 74 69 61 6c 69 74 65 2f 77  /libspatialite/w
00a0: 69 6b 69 3f 6e 61 6d 65 3d 35 2e 30 2e 30 2d 64  iki?name=5.0.0-d
00b0: 6f 63 22 3e 6d 61 69 6e 20 53 70 61 74 69 61 4c  oc">main SpatiaL
00c0: 69 74 65 20 70 61 67 65 3c 2f 61 3e 0d 0a 3c 68  ite page</a>..<h
00d0: 32 3e 52 65 61 64 69 6e 67 20 53 48 50 20 61 6e  2>Reading SHP an
00e0: 64 20 44 42 46 20 66 69 6c 65 73 20 64 69 72 65  d DBF files dire
00f0: 63 74 6c 79 20 66 72 6f 6d 20 77 69 74 68 69 6e  ctly from within
0100: 20 61 20 5a 69 70 66 69 6c 65 3c 2f 68 32 3e 0d   a Zipfile</h2>.
0110: 0a 53 74 61 72 74 69 6e 67 20 73 69 6e 63 65 20  .Starting since 
0120: 76 65 72 73 69 6f 6e 20 3c 62 3e 35 2e 30 2e 30  version <b>5.0.0
0130: 3c 2f 62 3e 20 53 70 61 74 69 61 4c 69 74 65 20  </b> SpatiaLite 
0140: 68 61 73 20 74 68 65 20 63 61 70 61 62 69 6c 69  has the capabili
0150: 74 79 20 74 6f 20 64 69 72 65 63 74 6c 79 20 72  ty to directly r
0160: 65 61 64 20 61 6e 79 20 3c 62 3e 53 68 61 70 65  ead any <b>Shape
0170: 66 69 6c 65 3c 2f 62 3e 20 28 6f 72 20 3c 62 3e  file</b> (or <b>
0180: 44 42 46 3c 2f 62 3e 20 66 69 6c 65 29 20 63 6f  DBF</b> file) co
0190: 6e 74 61 69 6e 65 64 20 77 69 74 68 69 6e 20 61  ntained within a
01a0: 20 63 6f 6d 70 72 65 73 73 65 64 20 3c 62 3e 5a   compressed <b>Z
01b0: 69 70 66 69 6c 65 3c 2f 62 3e 2e 3c 62 72 3e 0d  ipfile</b>.<br>.
01c0: 0a 53 65 76 65 72 61 6c 20 63 6c 6f 73 65 6c 79  .Several closely
01d0: 20 72 65 6c 61 74 65 64 20 53 51 4c 20 66 75 6e   related SQL fun
01e0: 63 74 69 6f 6e 73 20 68 61 76 65 20 62 65 65 6e  ctions have been
01f0: 20 69 6e 74 72 6f 64 75 63 65 64 20 61 73 20 77   introduced as w
0200: 65 6c 6c 2e 0d 0a 3c 68 33 3e 41 63 63 65 73 73  ell...<h3>Access
0210: 69 6e 67 20 61 20 5a 69 70 70 65 64 20 53 48 50  ing a Zipped SHP
0220: 3c 2f 68 33 3e 0d 0a 41 6c 6c 20 74 68 65 73 65  </h3>..All these
0230: 20 6e 65 77 20 53 51 4c 20 66 75 6e 63 74 69 6f   new SQL functio
0240: 6e 73 20 61 72 65 20 6e 6f 77 20 73 75 70 70 6f  ns are now suppo
0250: 72 74 65 64 3a 0d 0a 3c 75 6c 3e 0d 0a 3c 6c 69  rted:..<ul>..<li
0260: 3e 3c 62 3e 49 6d 70 6f 72 74 5a 69 70 53 48 50  ><b>ImportZipSHP
0270: 28 29 3c 2f 62 3e 3a 20 74 68 65 20 6d 61 69 6e  ()</b>: the main
0280: 20 66 75 6e 63 74 69 6f 6e 20 61 6c 6c 6f 77 69   function allowi
0290: 6e 67 20 74 6f 20 69 6d 70 6f 72 74 20 61 20 77  ng to import a w
02a0: 68 6f 6c 65 20 53 68 61 70 65 66 69 6c 65 20 69  hole Shapefile i
02b0: 6e 74 6f 20 61 20 6e 65 77 20 53 70 61 74 69 61  nto a new Spatia
02c0: 6c 20 54 61 62 6c 65 20 69 6e 74 6f 20 74 68 65  l Table into the
02d0: 20 63 75 72 72 65 6e 74 6c 79 20 63 6f 6e 6e 65   currently conne
02e0: 63 74 65 64 20 44 61 74 61 62 61 73 65 2e 3c 2f  cted Database.</
02f0: 6c 69 3e 0d 0a 3c 6c 69 3e 3c 62 3e 50 52 4f 4a  li>..<li><b>PROJ
0300: 5f 47 75 65 73 73 53 72 69 64 46 72 6f 6d 5a 69  _GuessSridFromZi
0310: 70 53 48 50 28 29 3c 2f 62 3e 3a 20 61 20 68 65  pSHP()</b>: a he
0320: 6c 70 65 72 20 66 75 63 74 69 6f 6e 20 66 6f 72  lper fuction for
0330: 20 61 74 74 65 6d 70 74 69 6e 67 20 74 6f 20 67   attempting to g
0340: 75 65 73 73 20 74 68 65 20 53 52 49 44 20 66 6f  uess the SRID fo
0350: 72 20 61 20 67 69 76 65 6e 20 7a 69 70 70 65 64  r a given zipped
0360: 20 53 48 50 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e   SHP.</li>..<li>
0370: 3c 62 3e 5a 69 70 66 69 6c 65 5f 4e 75 6d 53 48  <b>Zipfile_NumSH
0380: 50 28 29 3c 2f 62 3e 3a 20 61 20 68 65 6c 70 65  P()</b>: a helpe
0390: 72 20 66 75 6e 63 74 69 6f 6e 20 72 65 74 75 72  r function retur
03a0: 6e 69 6e 67 20 74 68 65 20 74 6f 74 61 6c 20 63  ning the total c
03b0: 6f 75 6e 74 20 6f 66 20 53 68 61 70 65 66 69 6c  ount of Shapefil
03c0: 65 73 20 63 6f 6e 74 61 69 6e 65 64 20 77 69 74  es contained wit
03d0: 68 69 6e 20 61 20 67 69 76 65 6e 20 5a 69 70 66  hin a given Zipf
03e0: 69 6c 65 2e 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e 3c  ile.</li>..<li><
03f0: 62 3e 5a 69 70 66 69 6c 65 5f 53 68 70 4e 28 29  b>Zipfile_ShpN()
0400: 3c 2f 62 3e 3a 20 61 20 68 65 6c 70 65 72 20 66  </b>: a helper f
0410: 75 6e 63 74 69 6f 6e 20 72 65 74 75 72 6e 69 6e  unction returnin
0420: 67 20 74 68 65 20 3c 62 3e 3c 69 3e 62 61 73 65  g the <b><i>base
0430: 6e 61 6d 65 3c 2f 69 3e 3c 2f 62 3e 20 66 6f 72  name</i></b> for
0440: 20 74 68 65 20 3c 62 3e 4e 74 68 3c 2f 62 3e 20   the <b>Nth</b> 
0450: 53 68 61 70 65 66 69 6c 65 20 63 6f 6e 74 61 69  Shapefile contai
0460: 6e 65 64 20 77 69 74 68 69 6e 20 61 20 67 69 76  ned within a giv
0470: 65 6e 20 5a 69 70 66 69 6c 65 2e 3c 2f 6c 69 3e  en Zipfile.</li>
0480: 0d 0a 3c 2f 75 6c 3e 0d 0a 3c 62 72 3e 0d 0a 57  ..</ul>..<br>..W
0490: 65 27 6c 6c 20 6e 6f 77 20 73 74 61 72 74 20 61  e'll now start a
04a0: 20 71 75 69 63 6b 20 74 75 74 6f 72 69 61 6c 20   quick tutorial 
04b0: 61 62 6f 75 74 20 75 73 69 6e 67 20 61 6c 6c 20  about using all 
04c0: 74 68 65 73 65 20 6e 65 77 20 53 51 4c 20 66 75  these new SQL fu
04d0: 6e 63 74 69 6f 6e 73 2e 0d 0a 3c 76 65 72 62 61  nctions...<verba
04e0: 74 69 6d 3e 0d 0a 53 45 4c 45 43 54 20 5a 69 70  tim>..SELECT Zip
04f0: 66 69 6c 65 5f 4e 75 6d 53 48 50 20 28 20 27 63  file_NumSHP ( 'c
0500: 3a 2f 75 73 65 72 73 2f 61 66 75 72 69 2f 44 6f  :/users/afuri/Do
0510: 77 6e 6c 6f 61 64 73 2f 4c 69 6d 69 74 69 30 31  wnloads/Limiti01
0520: 30 31 32 30 32 30 2e 7a 69 70 27 20 29 0d 0a 2d  012020.zip' )..-
0530: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0d 0a 34 0d 0a  -----------..4..
0540: 3c 2f 76 65 72 62 61 74 69 6d 3e 0d 0a 3c 62 72  </verbatim>..<br
0550: 3e 3c 62 72 3e 0d 0a 3c 68 72 3e 0d 0a 3c 68 33  ><br>..<hr>..<h3
0560: 3e 41 63 63 65 73 73 69 6e 67 20 61 20 5a 69 70  >Accessing a Zip
0570: 70 65 64 20 44 42 46 3c 2f 68 33 3e 0d 0a 41 6c  ped DBF</h3>..Al
0580: 6c 20 74 68 65 73 65 20 6e 65 77 20 53 51 4c 20  l these new SQL 
0590: 66 75 6e 63 74 69 6f 6e 73 20 61 72 65 20 6e 6f  functions are no
05a0: 77 20 73 75 70 70 6f 72 74 65 64 3a 0d 0a 3c 75  w supported:..<u
05b0: 6c 3e 0d 0a 3c 6c 69 3e 3c 62 3e 49 6d 70 6f 72  l>..<li><b>Impor
05c0: 74 5a 69 70 44 42 46 28 29 3c 2f 62 3e 3a 20 74  tZipDBF()</b>: t
05d0: 68 65 20 6d 61 69 6e 20 66 75 6e 63 74 69 6f 6e  he main function
05e0: 20 61 6c 6c 6f 77 69 6e 67 20 74 6f 20 69 6d 70   allowing to imp
05f0: 6f 72 74 20 61 20 77 68 6f 6c 65 20 44 42 46 20  ort a whole DBF 
0600: 66 69 6c 65 20 69 6e 74 6f 20 61 20 6e 65 77 20  file into a new 
0610: 54 61 62 6c 65 20 69 6e 74 6f 20 74 68 65 20 63  Table into the c
0620: 75 72 72 65 6e 74 6c 79 20 63 6f 6e 6e 65 63 74  urrently connect
0630: 65 64 20 44 61 74 61 62 61 73 65 2e 3c 2f 6c 69  ed Database.</li
0640: 3e 0d 0a 3c 6c 69 3e 3c 62 3e 5a 69 70 66 69 6c  >..<li><b>Zipfil
0650: 65 5f 4e 75 6d 44 42 46 28 29 3c 2f 62 3e 3a 20  e_NumDBF()</b>: 
0660: 61 20 68 65 6c 70 65 72 20 66 75 6e 63 74 69 6f  a helper functio
0670: 6e 20 72 65 74 75 72 6e 69 6e 67 20 74 68 65 20  n returning the 
0680: 74 6f 74 61 6c 20 63 6f 75 6e 74 20 6f 66 20 44  total count of D
0690: 42 46 20 66 69 6c 65 73 20 63 6f 6e 74 61 69 6e  BF files contain
06a0: 65 64 20 77 69 74 68 69 6e 20 61 20 67 69 76 65  ed within a give
06b0: 6e 20 5a 69 70 66 69 6c 65 2e 3c 2f 6c 69 3e 0d  n Zipfile.</li>.
06c0: 0a 3c 6c 69 3e 3c 62 3e 5a 69 70 66 69 6c 65 5f  .<li><b>Zipfile_
06d0: 44 62 66 4e 28 29 3c 2f 62 3e 3a 20 61 20 68 65  DbfN()</b>: a he
06e0: 6c 70 65 72 20 66 75 6e 63 74 69 6f 6e 20 72 65  lper function re
06f0: 74 75 72 6e 69 6e 67 20 74 68 65 20 3c 62 3e 3c  turning the <b><
0700: 69 3e 66 69 6c 65 6e 61 6d 65 3c 2f 69 3e 3c 2f  i>filename</i></
0710: 62 3e 20 66 6f 72 20 74 68 65 20 3c 62 3e 4e 74  b> for the <b>Nt
0720: 68 3c 2f 62 3e 20 44 42 46 20 66 69 6c 65 20 63  h</b> DBF file c
0730: 6f 6e 74 61 69 6e 65 64 20 77 69 74 68 69 6e 20  ontained within 
0740: 61 20 67 69 76 65 6e 20 5a 69 70 66 69 6c 65 2e  a given Zipfile.
0750: 3c 2f 6c 69 3e 0d 0a 3c 2f 75 6c 3e 0d 0a 0d 0a  </li>..</ul>....
0760: 3c 62 72 3e 3c 68 72 3e 3c 62 72 3e 0d 0a 42 61  <br><hr><br>..Ba
0770: 63 6b 20 74 6f 20 3c 61 20 68 72 65 66 3d 22 68  ck to <a href="h
0780: 74 74 70 73 3a 2f 2f 77 77 77 2e 67 61 69 61 2d  ttps://www.gaia-
0790: 67 69 73 2e 69 74 2f 66 6f 73 73 69 6c 2f 6c 69  gis.it/fossil/li
07a0: 62 73 70 61 74 69 61 6c 69 74 65 2f 77 69 6b 69  bspatialite/wiki
07b0: 3f 6e 61 6d 65 3d 35 2e 30 2e 30 2d 64 6f 63 22  ?name=5.0.0-doc"
07c0: 3e 6d 61 69 6e 20 53 70 61 74 69 61 4c 69 74 65  >main SpatiaLite
07d0: 20 70 61 67 65 3c 2f 61 3e 0a 5a 20 62 64 63 32   page</a>.Z bdc2
07e0: 66 39 66 36 32 64 39 38 37 65 31 61 32 39 64 35  f9f62d987e1a29d5
07f0: 62 31 62 31 65 62 30 39 62 36 38 34 0a           b1b1eb09b684.