Converting sqlite (spatialite) data to oracle sdo_geometry (using .NET)

Converting sqlite (spatialite) data to oracle sdo_geometry (using .NET)

Using .NET, I have a sqlite file that I have to import to oracle. The geometry needs to be converted from sqlite (spatialite) geometry column to a sdo_geometry column in oracle:

// Loop through all records in sqlite file foreach (DataRow row in dsSqLite.Tables["Default"].Rows) { // Get geometry field from sqlite and get it ready for oracle format NetSdoGeometry.sdogeometry geom = row["GEOMETRY"]; // ERROR HERE }

When I execute the above, I get an error "Unable to cast object of type 'System.Byte[]' to type 'NetSdoGeometry.sdogeometry'. Also I do not see where to specify the SRID. Does anyone know the correct way to convert the geometry column from spatialite to oracle sdo_geometry?

References: NetSdoGeometry library:

From what I see, NetSdoGeometry works only by READING geometries from Oracle into some .net object. I don't see a place where it does the reverse.

Maybe a much simpler solution is to use gdal (ogr2ogr) do copy the content from sqlite into Oracle. See for details about that driver.

Use SCOPE_IDENTITY() if you are inserting a single row and want to retrieve the ID that was generated.

Use the OUTPUT clause if you are inserting multiple rows and need to retrieve the set of IDs that were generated.

and why this is best faster option?

Performance aside, these are the only ones that are guaranteed to be correct in the default isolation level and/or with multiple users. Even if you ignore the correctness aspect, SQL Server holds the inserted value in SCOPE_IDENTITY() in memory, so naturally this will be faster than going and running your own isolated query against the table or against system tables.

Ignoring the correctness aspect is like telling the mailman he did a good job delivering today's mail - he finished his route 10 minutes faster than his average time, the problem is, none of the mail was delivered to the right house.

Do not use any of the following:

  • @@IDENTITY - since this can't be used in all scenarios, for example when a table with an identity column has a trigger that also inserts into another table with its own identity column - you will get the wrong value back.
  • IDENT_CURRENT() - I go into detail about this here, and the comments are useful reading as well, but essentially, under concurrency, you will often get the wrong answer.
  • MAX() or TOP 1 - you would have to protect the two statements with serializable isolation in order to ensure that the MAX() you get isn't someone else's. This is much more expensive than just using SCOPE_IDENTITY() .

These functions also fail whenever you insert two or more rows, and need all the identity values generated - your only option there is the OUTPUT clause.

Converting sqlite (spatialite) data to oracle sdo_geometry (using .NET) - Geographic Information Systems

Koordinat2 WebApp ( was developed using ReactJS and WebAssembly for converting geo-coordinates and showing them on a map. The WebApp uses Proj4 in the backend for performing the projection conversion and datum conversion hence it supports over a thousand coordinate reference systems.

Using the Koordinat2 WebApp is easy. The following shows what can be done with the WebApp.

    Using a modern browser, open up the the Koordinat2 WebApp at this url

The WebApp page is displayed.

Choosing Coordinate Systems

    To define the primary input coordinate system, click the gear icon in the Input Coordinates panel.

The Select Source Coordinate System dialog appears.

One or more entries are listed.

The selected coordinate system is chosen.

Converting Coordinates

    To convert coordinates in the Input Coordinate system, type in the Easting and Northing (or Latitude and Longitude) values in the corresponding entry fields.

The converted coordinates are displayed immediately in the Output Coordinates Longitude and Latitude fields (or Easting and Northing fields).

A corresponding marker is also created on the Map pointing to the location of the coordinate.

Displaying Coordinates of Map Locations

    To display coordinates of locations on the map, simply click the map location with the mouse.

A marker is placed at the clicked location.

    On the toolbar on the top right, click the Grid icon.

The Select Grid Settings dialog box appears.

Selecting a Base Layer

    On the tool bar on the top right, click the Layer icon.

Converting sqlite (spatialite) data to oracle sdo_geometry (using .NET) - Geographic Information Systems

GIS ObjectLand is a universal Geographic Information System for Windows.Key features:- creation of vector-raster maps with arbitrary structure of layers and feature types- creation of themes. Theme is a user presentation of a map- control of displaying features depending on the chosen scale- spatial data input and editing by assigning feature. Free download of GIS ObjectLand 2.6.5, size 24.76 Mb.

Algolab Raster to Vector Conversion CAD/GIS SDK 2.55 AlgoLab Inc.

Software development kit for CAD/CAM/ GIS and graphic software developers. Converts from raster to vector and refines architect, mechanical, tech drawing, maps, math graphs, graphics for books and journals and more. ActiveX and Com Component are also available. Refines vector graphics, creates fine lines and shapes. Scanned drawings are recognized. Free download of Algolab Raster to Vector Conversion CAD/GIS SDK 2.55, size 2.87 Mb.

AvisMap GIS Engine 5.0.1 AvisMap GIS Technologies

AvisMap GIS Engine is a comprehensive SDK for the development of custom GIS applications and solutions. This SDK provides several ActiveX (OCX) controls which support Visual Basic, VB.NET, C#, Visual C++ and other ActiveX compatible programming languages, with Microsoft Visual Studio versions 6, 2003, 2005, and Express. Supports .NET via COM. While. Free download of AvisMap GIS Engine 5.0.1, size 45.89 Mb.

Canvas GIS Advanced (Mac) 9.0.4 ACD Systems

The CANVAS 9 Advanced GIS Mapping Edition adds native support for Geographic Information System (GIS) data to Canvas. You can take measurements in geographic coordinates, import industry standard SHAPE and GeoTIFF files into unlimited numbers of automatically aligned overlapping layers and choose among the following options:E2,104 Coordinate. Free download of Canvas GIS Advanced (Mac) 9.0.4, size 54.42 Mb.

Canvas GIS Mapping Edition (Mac) 9.0.4 ACD Systems

The CANVAS 9 GIS Mapping Edition adds native support for Geographic Information System (GIS) data to Canvas. You can take measurements in geographic coordinates, import industry standard SHAPE and GeoTIFF files into unlimited numbers of automatically aligned overlapping layers and choose among the following options:2,104 Coordinate Reference. Free download of Canvas GIS Mapping Edition (Mac) 9.0.4, size 54.42 Mb.

CMS Xpandy Powered by IntelliCAD 6.3 CAD Manufacturing Solutions, Inc.

If you are unable to purchase the latest intellicad Technology, then you found the right software. CMS Xpandy Powered by IntelliCAD 6.3 Technology allows you freely to use a reliable IntelliCAD based CAD application. You can also create and publish your own ads using Xpandy Technology. System extra requirements: Microsoft .NET 2.0 Framework, and an. Freeware download of CMS Xpandy Powered by IntelliCAD 6.3, size 54.78 Mb.

ProgeCAD Standard IntelliCAD Software 2011 CADDIT CAD Software

progeCAD IntelliCAD edits AutoCAD DWG CAD files on Windows 7, Windows XP and Vista at minimal cost. Edit AutoCAD DWG 2010 files, DXF read and write. Similar icons, commands and interface.IntelliCAD AutoLISP interpreter, temporary point snap (like oSnap), layers,blocks. For complete CAD drawing we strongly recommend progeCAD Professional instead,. Free download of progeCAD Standard IntelliCAD Software 2011, size 212.46 Mb.

Quantum GIS Tethys 1.5-r13926-1 QGIS Development Team

The Quantum GIS Tethys repository contains a lot of software from OSGeo projects. Quantum GIS Tethys and all dependencies are included, along with Python, GRASS, GDAL, etc. This is most suitable for people who want to be able to update dependencies from the Quantum GIS Tethys repository easily. The installer is able to install from internet or just. Freeware download of Quantum GIS Tethys 1.5-r13926-1, size 377.86 Kb.

My World GIS 4. 1. 2011 Northwestern University

With the new Icons-Land Vista Style GIS/GPS/Map Icon Set now it is much more comfortable to use local service applications, GPS tracking and GIS applications, and any kind of mapping applications. GIS/GPS/Map Icons are meant to help users to orient oneself when using maps, to facilitate their search of definite objects and make maps more. Free download of Icons-Land Vista Style GIS / GPS / MAP Icon Set 2.0, size 0 b.

Map Suite GIS Editor Beta ThinkGeo LLC

Map Suite GIS Editor is a feature-packed application that allows teachers and students alike design maps, analyze geographic data and visualize it.

Its intuitive interface comes in handy to beginners who want to get familiarized with GIS (Geographical Information System), yet the application is complex enough to leave plenty of room for. Free download of Map Suite GIS Editor Beta, size 0 b.

ProgeCAD 2009 Professional IntelliCAD 2009.0.28.7

progeCAD IntelliCAD uses AutoCAD DWG files, no need for conversion. Windows 7 32,Windows 7 64, No learning curve for AutoCAD users. AutoLISP, VBA, ADS programming, import from PDF, Advanced Rendering, 3D ACIS Solid Modeling included. For architects, building kitchen and bath designers, civil, electrical, AEC, MEP and structural engineers, road,. Free download of progeCAD 2009 Professional IntelliCAD 2009.0.28.7, size 163.28 Mb.

Map Export Offlinesoft

Map Export is a GIS developer oriented tool for downloading and exporting background image.For a long time, as a GIS developer, It’s well known that to find perfect background images is a suffering and painful task. But since the growing up of Google Map, things have been changed. Google Map provides a wonderful resource of background images. Free download of Map Export, size 2.47 Mb.

AGIS for Windows 2002 AGIS Software Pty Ltd

AGIS for Windows is a mapping and simple GIS shareware package. Plot your own geographic data on the map of the world provided without the high cost and steep learning curve usually associated with this kind of software. Create high resolution publication quality images that can be pasted into popular packages such as MS Word. Animation, web. Free download of AGIS for Windows 2002, size 3.67 Mb.

GStarICAD Std 2007-11-1 Great Star Software Technology Co.,Ltd

GStarICAD is based on IntelliCAD software, the industry standard for low-cost CAD software.GStarICAD is the innovative alternative to AutoCAD that provides OpenDWG file compatibility, similar environment, full support for AutoCAD commands, menus, scripts, styles, patterns etc.GStarICAD is the top quality version of IntelliCAD worldwide, 99%. Free download of GStarICAD Std 2007-11-1, size 36.62 Mb.

VSceneGIS Desktop 0.9.2u2

Customer Project Development, Analysis, Computing and GIS editing. VSceneGIS Desktop applies the concept of Tree and Graph Topology to implement the data model in a GIS. Validation, Editing and Topological Behavior
Export and import of data sources: PostgreSQL / PostGIS, Oracle, MySQL, SQLite / SpatiaLite, ShapeFile.
Connection to. Freeware download of VSceneGIS Desktop 0.9.2u2, size 124.16 Mb.

Shape2Earth 1.490 Google

Shape2Earth leverages freely available and easy to use Geographic Information System (GIS) software to create professional visualizations for viewing in GoogleTM Earth.

Main features:
-Convert Any Shapefile to KML - Shape2Earth reprojects your data on the fly
-Apply Thematic Symbology to your Data - Color code to display. Free download of Shape2Earth 1.490, size 1.48 Mb.

PlanetGIS Explorer Planet GIS

PlanetGIS Explorer is a free viewer for PlanetGIS maps and GIS exchange files. PlanetGIS Explorer allows you to navigate through maps, query map elements and view attribute information from linked database tables. Also PlanetGIS Explorer allows you to customize the appearance of maps for purposes of creating hardcopy printouts, but does not allow. Freeware download of PlanetGIS Explorer, size 5.68 Mb.

Gismaps Viewer 1. 3. 3524 Gismaps Sistemas Ltda.

Gismaps Viewer is a GIS viewer that can be used for geospatial analysis and map production.

The main features are:
- read Shape files using geographic coordinate system
- view satellite images (MrSid, jpeg, bmp and tiff file formats)
- generate thematic maps, queries and labels
- export do Google Earth KML. Freeware download of Gismaps Viewer 1. 3. 3524, size 10.65 Mb.

InfoMate 3 1 Compuplot

InfoMate is a complete survey computation, fieldwork reduction, data capture and translation environment, aimed at Local Government, Land Surveyors, Municipalities and the GIS community. InfoMate provides tools for the fast and efficient capture of spatial and attribute data. This data is processed, maintained and presented as topologically sound,. Free download of InfoMate 3 1, size 32.42 Mb.

Si tienes SQL Server 2008+, puedes convertirlo a DATE :

Si no, puedes convertirlo a un string que contenga sólo el año, mes y día:

Para convertir el campo fecha al formato YYYY-MM-DD en SQL Server 2008 R2, puedes usar la función CONVERT con los parámetros siguientes:

Si el formato que quieres es mas bien DD-MM-YYYY , entonces sería de esta forma:

¿Cómo puedo obtener fechas sin horas ni minutos en una consulta de SQL para utilizar un COUNT?

Si simplemente necesitas la porción fecha sin la hora para poder hacer una cuenta, entonces el formato del campo no tiene importancia. En este caso, lo más sencillo es de simplemente hacer un CAST a tipo DATE :

GeoDjango A:安装 转载


1. :ref:`python24` and :ref:`django` /*安装python平台及django框架*/
2. :ref:`spatial_database` /*空间数据库,如PostgresSQL*/
3. :ref:`geospatial_libs` /*空间类库*/

Details for each of the requirements and installation instructions
are provided in the sections below. In addition, platform-specific
instructions are available for:

.. admonition:: Use the Source

Because GeoDjango takes advantage of the latest in the open source geospatial
software technology, recent versions of the libraries are necessary.
Unfortunately, binary packages are not available on many GNU/Linux systems
(GEOS 3, in particular). Thus, `installation from source`_ may be required.
When compiling the libraries from source, please follow the directions closely,
especially if you're a beginner.

.. _installation from source: install.html#building-from-source

Python 2.4+
Because of heavy use of the decorator syntax, Python 2.4 is minimum
version supported by GeoDjango. Python 2.5+ is recommended because the
`ctypes`__ module comes included otherwise, 2.4 users will need to
`download and install ctypes`__.

Because GeoDjango is included with Django, please refer to Django's
`installation instructions`__ for details on how to install.

Spatial Database
PostgreSQL (with PostGIS), MySQL, and Oracle are the spatial databases
currently supported.
.. note ::

PostGIS is recommended, because it is the most mature and feature-rich
open source spatial database.
/ *此处使用推荐的PostgreSQL*/
The geospatial libraries required for a GeoDjango installation depends
on the spatial database used. The following lists the library requirements,
supported versions, and any notes for each of the supported spatial

Geospatial Libraries
GeoDjango uses and/or provides interfaces for the the following open source
geospatial libraries:

While GDAL is optional, it is recommended because some GeoDjango utilities and
functionality depend on its installation.

The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
independently of Django. In other words, no database or settings file
required -- just import them as normal from ``django.contrib.gis``.

.. _GEOS: geos.html
.. _GDAL: gdal.html
.. _GeoIP: geoip.html


When installing from source on UNIX and GNU/Linux systems, please follow
the installation instructions carefully, and install the libraries in the
given order. If using MySQL or Oracle as the spatial database, only GEOS
is required.

GEOS is a C++ library for performing geometric operations, and is the default
internal geometry representation used by GeoDjango (it's behind the "lazy"
geometries). Specifically, the C API library is called (e.g., ````)
directly from Python using ctypes.

First, download GEOS 3.0.2 from the refractions website and untar the source

$ wget
$ tar xjf geos-3.0.2.tar.bz2

Next, change into the directory where GEOS was unpacked, run the configure
script, compile, and install::

$ cd geos-3.0.2
$ ./configure
$ make
$ sudo make install
$ cd ..

When GeoDjango can't find GEOS, this error is raised::

ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.

The solution is to properly configure your :ref:`libsettings` *or* set
:ref:`geoslibrarypath` in your settings.

If your GEOS library is in a non-standard location, or you don't want to
modify the system's library path then the ``GEOS_LIBRARY_PATH`` setting
may be added to your Django settings file with the full path to the GEOS
C library. For example::

The setting must be the *full* path to the **C** shared library in
other words you want to use ````, not ````.

`PROJ.4`__ is a library for converting geospatial data to different coordinate
reference systems.

First, download the PROJ.4 source code and datum shifting files [#]_::

$ wget
$ wget

Next, untar the source code archive, and extract the datum shifting files in the
``nad`` subdirectory. This must be done *prior* to configuration::

$ tar xzf proj-4.6.1.tar.gz
$ cd proj-4.6.1/nad
$ tar xzf
$ cd ..

Finally, configure, make and install PROJ.4::

$ ./configure
$ make
$ sudo make install
$ cd ..

`PostGIS`__ adds geographic object support to PostgreSQL, turning it
into a spatial database. :ref:`geosbuild` and :ref:`proj4` should be
installed prior to building PostGIS.

The `psycopg2`_ module is required for use as the database adaptor
when using GeoDjango with PostGIS. Thus, the ``DATABASE_ENGINE``
Django setting needs to be ``postgresql_psycopg2``.

First download the source archive, and extract::

$ wget
$ tar xzf postgis-1.3.3.tar.gz
$ cd postgis-1.3.3

Next, find out PostgreSQL's 'share' directory, and specify it as the data root
directory when configuring. This ensures that PostGIS places its files in
a location consistent with the PostgreSQL installation::

$ ./configure --datadir=`pg_config --sharedir`

$ make
$ sudo make install
$ cd ..

GeoDjango does not automatically create a spatial database. Please
consult the section on :ref:`spatialdb_template` for more information.

`GDAL`__ is an excellent open source geospatial library that has support for
reading most vector and raster spatial data formats. Currently, GeoDjango only
supports GDAL's vector data capabilities [#]_. :ref:`geosbuild` and :ref:`proj4`
should be installed prior to building GDAL.

First download the latest GDAL version and untar the archive::

$ wget
$ tar xzf gdal-1.5.3.tar.gz
$ cd gdal-1.5.3

Configure, make and install::

$ ./configure
$ make # Go get some coffee, this takes a while.
$ sudo make install
$ cd ..

Because GeoDjango has it's own Python interface, the preceding instructions
do not build GDAL's own Python bindings. The bindings may be built by
adding the ``--with-python`` flag when running ``configure``. See
`GDAL/OGR In Python`__ for more information on GDAL's bindings.

If you have any problems, please see the troubleshooting section below for
suggestions and solutions.


When GeoDjango can't find the GDAL library, the ``HAS_GDAL`` flag
will be false::

>>> from django.contrib.gis import gdal
>>> gdal.HAS_GDAL

The solution is to properly configure your :ref:`libsettings` *or* set
:ref:`gdallibrarypath` in your settings.

If your GDAL library is in a non-standard location, or you don't want to
modify the system's library path then the ``GDAL_LIBRARY_PATH`` setting
may be added to your Django settings file with the full path to the GDAL
library. For example::

Can't find GDAL data files (``GDAL_DATA``)

When installed from source, GDAL versions 1.5.1 and below have an autoconf bug
that places data in the wrong location. [#]_ This can lead to error messages
like this::

ERROR 4: Unable to open EPSG support file gcs.csv.
OGRException: OGR failure.

The solution is to set the ``GDAL_DATA`` environment variable to the location of the
GDAL data files before infoking Python (typically ``/usr/local/share`` use
``gdal-config --datadir`` to find out). For example::

$ export GDAL_DATA=`gdal-config --datadir`
$ python shell

If using Apache, you may need to add this environment variable to your configuration

SetEnv GDAL_DATA /usr/local/share

Creating a spatial database with PostGIS is different than normal because
additional SQL must be loaded to enable spatial functionality. Because of
the steps in this process, it's better to create a database template that
can be reused later.

First, you need to be able to execute the commands as a privileged database
user. For example, you can use the following to become the ``postgres`` user::

Once you're a database super user, then you may execute the following commands
to create a PostGIS spatial database template::

$ createdb -E UTF8 template_postgis # Creating the template spatial database.
$ createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
$ psql -d template_postgis -f `pg_config --sharedir`/lwpostgis.sql # Loading the PostGIS SQL routines
$ psql -d template_postgis -f `pg_config --sharedir`/spatial_ref_sys.sql
$ psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC" # Enabling users to alter spatial tables.
$ psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC"

These commands may be placed in a shell script for later use for convenience,
the ``__ script is provided here.

Afterwards, you may create a spatial database by simply specifying
``template_postgis`` as the template to use (via the ``-T`` option)::

$ createdb -T template_postgis -U postgres -O <db user> <db name>

The ``createdb`` command must still be executed with the permissions of a
database super user (hence the ``-U postgres`` option). The database owner
(``-O`` option) is the database user that will own the new database you may need
to create with the ``createuser`` command if it does not exist.

Like other Django contrib applications, you will *only* need to add
``django.contrib.gis`` to ``INSTALLED_APPS`` in your settings. This is the
so that ``gis`` templates can be located -- if not done, then features such as
the geographic admin or KML sitemaps will not function properly.

In order to use the geographic admin with the OpenStreetMap base layer
(e.g., you want to use ``OSMGeoAdmin``), then the so-called "Google" projection
must be added to your spatial database's ``spatial_ref_sys`` table. Invoke
the Django shell from your project and execute the following command::

$ ./manage shell
>>> from django.contrib.gis.utils import add_postgis_srs
>>> add_postgis_srs(900913)

This adds an entry for the 900913 SRID to the ``spatial_ref_sys`` (or equivalent)
table, making it possible for the spatial database to transform coordinates in
this projection. You only need to execute this command *once* per spatial database.

If you can't find the solution to your problem here, then participate in the
community! You can:

* Join the ``#geodjango`` IRC channel on FreeNode (may be accessed via
* Ask your question on the `Django users`__ mailing list (make sure to have
"GeoDjango" in the text of your message).
* File a ticket on the `Django trac`__ if you think there's a bug. Make
sure to provide a complete description of the problem, versions used,
and specify the component as "GIS".


By far, the most common problem when installing GeoDjango is that the
external shared libraries (e.g., for GEOS and GDAL) cannot be located. [#]_
Typically, the cause of this problem is that the operating system isn't aware
of the directory where the libraries built from source were installed.

In general, the library path may be set on a per-user basis by setting
an environment variable, or configuring the library path for the entire

A user may set this environment variable to customize the library paths
they want to use. The typical library directory for software
built from source is ``/usr/local/lib``. Thus, ``/usr/local/lib`` needs
to be included in the ``LD_LIBRARY_PATH`` variable. For example, the user
could place the following in their bash profile::

On Mac OSX modify the ``DYLD_LIBRARY_PATH`` variable instead.

On GNU/Linux systems, there is typically a file in ``/etc/``, which may include
additional paths from files in another directory, such as ``/etc/``.
As the root user, add the custom library path (like ``/usr/local/lib``) on a
new line in ````. This is *one* example of how to do so::

$ sudo echo /usr/local/lib >> /etc/
$ sudo ldconfig

For OpenSolaris users, the system library path may be modified using the
``crle`` utility. Run ``crle`` with no options to see the current configuration
and use ``crle -l`` to set with the new library path. Be *very* careful when
modifying the system library path::

# crle -l $OLD_PATH:/usr/local/lib

Although OSX comes with Python installed, it is recommended that users
utilize the installers (ς.5`__ and ς.6`__ are available) provided by
the Python Software Foundation. This is recommended because:

#. OSX's Python will remain "pristine" for internal operating system use.
#. OSX's Python is not linked to GNU Readline library (meaning no colors in IPython).


You will need to modify your ``PATH`` so that the new version is invoked
from the shell when you invoke the ``python`` command. Please see the
:ref:`macenv` section for more details.

This method is no longer the recommended method to install GeoDjango on
Mac OSX. Specifically, MacPorts requires modification of the
``DYLD_LIBRARY_PATH`` enviornment variable, which may cause conflicts
for binaries linked to libraries native to the OS (for example libxml2,
or iconv). That said, this may simplify the install process for more
advanced users.

`MacPorts`__ may be used to install GeoDjango prerequisites on Macintosh
computers running OSX. Because MacPorts still builds the software from source, Apple's
Xcode 3.0 Developer Tools for the Leopard or 2.4.1 for Tiger are required. [#]_

$ sudo port install postgresql83-server
$ sudo port install geos
$ sudo port install proj
$ sudo port install postgis
$ sudo port install gdal
$ sudo port install libgeoip

Shell enviornment settings need to be set so that the proper Python installation is
used and so that GeoDjango may find the geospatial libraries. In order for these
settings to persist, they should be placed in your user's bash profile
(``.profile`` in your home directory).

The path needs to include the location of the Python installation and binary paths
used by MacPorts. The following should be okay (assuming the rest of the path
is provided in place of the ellipsis)::

This needs to include the default library and database library locations used
by MacPorts. The following should suffice::

GDAL versions 1.5.1 (used by MacPorts) and below have an autoconf bug that places
GDAL's data files in the wrong location. This environment variable should be set
so that GDAL may find its data::

First, download the `Python 2.5 installer`__ from the Python website. Next,
execute the installer and use defaults, i.e., keep 'Install for all users'
checked and the installation path set as ``C:Python25``.

You may already have a version of Python installed in ``C:python`` as ESRI
products sometimes install a copy there. *You should still install a
fresh version of Python 2.5.*

First, select a mirror and download the `PostgreSQL 8.3.3 installer`__ from the
PostgreSQL website.

Once downloaded, extract all files from the zipped folder and double-click on the
'postgresql-8.3' installer. During the PostgreSQL installation use only the default
options (i.e., keep the installation path as ``C:Program FilesPostgreSQL8.3``).

This PostgreSQL installation process will create both a new windows user to be the
'postgres service account' and a special 'postgres superuser' to own the database
cluster. You will be prompted to set a password for both users (make sure to write
them down!). To see basic details on the 'service user' account right click on
'My Computer' and select 'Manage' or go to: Control Panel -> Administrative Tools ->
Computer Management -> System Tools -> Local Users and Groups.

If installed successfully, the PostgreSQL server will run in the background each time
the system as started as a Windows service. When finished, the installer should launch
the Application Stack Builder (ASB) (which may be used to install PostGIS, see instructions
below). A 'PostgreSQL 8.3' start menu group should be created that contains shortcuts
for the ASB and 'Command Prompt', which launches a terminal window in the PostgreSQL

Launch the Application Stack Builder (Programs -> PostgreSQL 8.3), and select
'PostgreSQL Database Server 8.3 on port 5432' from the drop down menu. Next,
select 'PostGIS 1.3.3 for PostgreSQL 8.3' from the 'Spatial Extensions' tree
in the list. Select only the default options during install (do not uncheck
the option to create a default PostGIS database).

You will be prompted to enter your 'postgres superuser' password in the
'Database Connection Information' dialog.

The ``psycopg2`` Python module provides the interface between Python and the
PostgreSQL database. Download the `Windows installer`__ (v2.0.8) and run
using the default settings. [#]_

Download the `GeoDjango Installer`__ this was created [#]_ to simplify the rest
of the process for installing GeoDjango on Windows platforms. The installer
automatically installs Django 1.0, GDAL 1.5.0, PROJ.4, and configures the
necessary enviornment variables.

Once the installer has completed, log out and log back in so that the
modifications to the system environment variables take effect, and you
should be good to go.

The installer modifies the system ``Path`` environment variable to
include ``C:Program FilesPostgreSQL8.3in`` and
``C:Program FilesGeoDjangoin``. This is required so that Python
may find the GEOS DLL provided by PostGIS and the GDAL DLL provided
by the installer. The installer also sets the ``GDAL_DATA`` and
``PROJ_LIB`` enviornment variables.


python地理空间数据开发-[Erik_Westra]_Python_Geospatial_Development 清晰无水印版
Python Geospatial Development Copyright o 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews rt has been made in the preparation of this book to ensure the accuracy of the information presented However the information contained in this book is sold without warranty, cither express or implied. Neither the author nor Pacl Publishing and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information st published December 2010 Production reference: 1071210 Published by Packt Publishing ltd 32 Lincoln road Olto Birmingham b27 6PA, UK ISBN978-1-849511-54-4 Cover Image by asher Wishkerman(a. wishkermanompic de Table of contents Preface Chapter 1: Geo-Spatial Development Using Python 7 Python Geo-spatial development Applications of geo-spatial development 11 Analyzing geo-spatial data 12 Visualizing geo-spatial data 13 Creating a geo-spatial mash-up 16 Recent developments Summary 19 Chapter 2: GIs Core G|sc。 ncepts 21 ocation 22 Distance 25 Units 27 Projections 28 Cylindrical projections onic projection Azimuthal projections 31 The nature of map projections Coordinate systems 32 Datums 35 Shapes 36 Gis data formats 37 Working with Gis data manually 39 Summa Table of contents Chapter 3: Python Libraries for Geo-Spatial Development Reading and writing geo-spatial data 47 GDAL/OGR 48 GDAL design GDAL example code oGR design 51 OGR example code Documentation 53 Availability 53 Dealing with projections 54 nypro 54 Design 54 Pre 55 Geod Example code 57 Documentation 58 Availability 58 Analyzing and manipulating geo-s patial data 59 Shapely 59 Design 60 Example code 61 Documentation 62 Availabilit 62 Visualizing geo-spatial data 63 Mapnik 63 Design 64 EXample code 66 Documentation Availability 68 Summa 68 Chapter 4: Sources of Geo-Spatial Data Sources of geo-spatial data in vector format 72 Open StreetMap Data forma Obtaining and using Open StreetMap data 74 TIGER 76 Data format Obtaining and using TiGeR data 78 Digital Chart of the World 79 Data format 80 Available layers 80 Obtaining and using DCW data Table of Contents GSHHS 82 Data format Obtaining the GSHHs database World borders dataset 84 Data format 85 Obtaining the World Borders dataset Sources of geo-spatial data in raster format 85 Landsat 86 Data format Obtaining Landsat imagery 87 GLOBE 90 Data format 90 Obtaining and using globe data 91 National elevation dataset 92 Data format Obtaining and using Ned data Sources of other types of geo-spatial data 94 GEOnet Names server 94 Data format 95 Obtaining and using GEOnet Names Server data 5 GNIS 96 Data format 97 Obtaining and using GNIS data 97 Summar 98 Chapter 5: Working with Geo-Spatial Data in Python 101 Prerequisites 101 Reading and writing geo-spatial data 102 Task: Calculate the bounding box for each country in the world 102 Task: Save the country bounding boxes into a Shapefile 104 Task: Analyze height data using a digital elevation map 108 Changing datums and projections 115 Task: Change projections to combine Shapefiles using geographic and utm coordinates 115 Task: Change datums to allow older and newer tiger data to be combined 119 Representing and storing geo-spatial data 122 Task: Calculate the border between Thailand and myanmar 123 Task: Save geometries into a text file 126 Working with Shapely geometries 127 Task: Identify parks in or near urban areas 128 Converting and standardizing units of geometry and distance 132 Task: Calculate the length of the thai-Myanmar border 133 Task: Find a point 132.7 kilometers west of Soshone, California 139 Table of contents Exercises 141 Summar 143 Chapter 6: Gis in the Database 145 Spatially-enabled databases 145 Spatial indexes 146 Open source spatially-enabled databases 149 MySQL 149 PostGIs 152 Installing and configuring PostGIS 152 Using postGis 155 Documentation 157 Advanced postgis features 157 SpatiaLite 158 stalling SpatiaL Installing pysqlite 159 Accessing SpatiaLite from Python 160 Documentation 160 Using spatialite 161 Spatialite capabilities 163 Commercial spatially-enabled databases 164 Oracle 164 MS SQL Server 165 Recommended best practices 165 Use the database to keep track of spatial references 166 Option 2: Transform features as require cD o Use the appropriate spatial reference for your data 168 Option 1: Use a database that supports geographies 169 169 Option 3: Transform features from the outset When to use unprojected coordinates 170 Avoid on-the-fly transformations within a query 170 Don't create geometries within a query 171 Use spatial indexes appropriately 172 Know the limits of your database's query optimizer MySQL 174 PostGis 175 Spatialite 177 Working with geo-spatial databases using Python 178 Prerequisites 179 Working with My SQL 179 Working with PostGIS 182 Working with Spatialite 84 Speed comparisons 188 Summary 189 Table of Contents Chapter 7: Working with Spatial Data 191 about distal 191 Designing and building the database 195 Downloading the data 199 World borders dataset 200 GSHHS 200 Geonames 200 GEOnet Names server 200 Importing the data 201 World borders dataset 201 GSHHS 203 US placename data 205 Worldwide placename data 208 Implementing the DISTAL application 210 The"Select Country" script 212 The"Select Area"script 214 Calculating the bounding box 215 Calculating the map's dimensions 216 Setting up the datasource 218 Rendering the map image 220 The"Show Results"script 223 Identifying the clicked-on point 223 Identifying features by distance 225 Displaying the results 233 Application review and improvements 235 Usability 236 Quality 237 Placename issues 237 Lat/Long coordinate problems 238 Performance 239 Finding the problem 240 Improving performance 242 Calculating the tiled shorelines Using the tiled shorelines 250 Analyzing the performance improvement 252 Further performance improvements 25 Scalability 253 uma 257 Chapter 8: Using Python and Mapnik to Generate Maps 259 Introducing Mapnik 260 Creating an example map 265 Mapnik in depth 269 Data sources 269 Shapefilt 270 Table of contents PostGis 270 GDAl OGR 273 SQLite 274 OSM 275 PointDatasource Rules, filters and styles 277 Filters 277 Scale denominators 279 Ese rules 280 Symbolizes 281 Drawing lines 281 awing polyg 287 Drawing labels 289 Drawing points 298 Drawing raster images 301 Using colors Maps and layers 304 Map attributes and methods 305 ayer attributes and methods 306 Map rendering 307 Map generator revisited 309 The MapGenerator's interface 309 Creating the main map layer 310 Displaying points on the map 312 Rendering the map 313 What the map generator teaches us 313 Map definition files 314 Summary 317 Chapter 9: Web Frameworks for Python Geo-Spatial Development 321 Web application concepts 322 Web application architecture 322 a bare-bones approach 322 Web application stacks 323 Web application frameworks 324 Web services 325 Map rendering 327 Tile caching 327 Web servers 330 User interface libraries 331 The slippy map"stack 332 The geo-spatial web application stack 334 Table of Contents Protocols 334 The Web Map Service(WMS) protocol 334 WMS-C 337 The Web Feature Service(WFS) protocol 337 The TMs (Tile Map Service) protocol 339 Tools 344 Tile caching 344 Tile Cache 345 mod tile 346 Tillite 347 User interface libraries 347 OpenLayers 348 Mapiator 351 Web application frameworks 353 GeoDⅰango 353 MapFish Turbo Gears 357 Summary 359 Chapter 10: Putting it All Together: A Complete Mapping Application 363 About the shapeEditor 363 Designing the application 36 Importing a shapefile 367 Selecting a feature 369 Editing a feature 370 Exporting a Shapefile 371 Prerequisites 371 The structure of a Django application 372 Models 374 Vⅰews 374 Templates 377 Setting up the database 379 Setting up the GeoDjango project 380 Setting up the shape Editor application 382 Defining the data models 383 Shapefile 383 Attribute 384 Feature 384 Attribute∨a|ue 385 The models. py file 385 Playing with the admin system 388 Summary 395

试读 127P

Watch the video: Spatialite GUI - SQLIte - Create a New Empty SQLite Database - Part II