Duncan Golicher’s weblog

Research, scripts and life in Chiapas

Archive for August 2008

Como georeferenciar fotos con precisión sin costo ni esfuerzo

with 3 comments

Camaras digitales con un GPS integrado siguen siendo bastante costosas para proyectos de investigación de bajos recursos. Pero acabo de descubrir como se puede usar cualquier camara digital y cualquier GPS en exactamente la misma forma. El secreto es sincronizar la hora de ambos aparatos exactamente. Luego el software gpicsync hace toda la operación de añadir un código geográfico al encabezado EXIF e incluso escribe un kml para Google Earth con las fotos integradas. Un programa alternativo es gpscorrelate (que hace algo parecido a lo que se me ocurrió tratar de hacer si no habia encontrado gipsync antes). Gpicsync es muy fácil de usar y parece bien confiable. Hay versiones de gpicsync para Windows y Linux disponibles.

http://code.google.com/p/gpicsync/

No hay un instalador automatica para Ubuntu, pero se puede bajar con subversión.

svn checkout http://gpicsync.googlecode.com/svn/trunk/ gpicsync

Nota que para la versión Linux hay que asegurar que tienes todas las dependencias. En Ubuntu dado de que no se instala usando aptitude el proceso no es automático. El archivo “readme.txt” tampoco es muy específico cuales son. La instalación de python-wxgtk2.8, libexif12 y libimage-exiftool-perl debe solucionar los problemas. Se arranca el programa con python, entonces en en mi caso tengo un “launcher” con

python /home/duncan/gpicsync/gpicsync-GUI.py

La otra herramienta necesaria es gpsbabel. Esta programa maravilloso puede hacer la conversión entre casi cualquier formato de gps. No tiene GUI. Funciona en la mism forma desde la linea de comandos tanto en Windows como Linux. Aunque hay que revisar un poco su documentaticón antes de empezar, el uso rutinario no es nada complicado.

Obviamente el primer paso es asegurar que la hora de la camara es correcta al segundo. Nota que los gps graban la hora en UTC, pero gpicsync tiene una opción para ajustar a diferentes zonas, asi que deja la camera con la hora local.

Todavía no he probado el uso del programa ni en Windows ni con un Garmin, pero si el aparato esta conectado al puerto serial este comando debe bajar los datos del “tracklog” guardándolo en el formato gpx, lo cual es necesario para el programa.

gpsbabel -t -i garmin -f com1 -o gpx -F tracklog.gpx

Para mi uso personal tengo un gps NMEA basico que compré por $US30 en los Estado Unidos. Se conecta al USB del laptop. Estos aparatos económicos son tan precisos como cualquier Garmin o Magellan (usa WAAS si es disponible), pero requieren una laptop o palm para su uso, no funcionan independientemente.  Dado el costo bajo de la tecnología se supone que dentro de muy poco sería rutinario tener un GPS integrado en las laptops. Hay varios programas  disponibles en Linux que proveen un interface gráfico para un GPS de este tipo.

Viking, GPSDrive y gpsman son ejemplos. Son funcionales, pero para decir la verdad podrían beneficiarse de mejores interfaces para ser mas amigables. Nota que debes instalar un pequeño programa de conversión primero llamado gpsd. Esta forma un interface entre el aparato y el laptop con el comando  gpsd /dev/ttyUSB0 (suponiendo el aparato esta en el USB). Se puede ver si esta funcionando con el programa xgps. Un aviso. He encontrado que si se desconecta el gps y se reconecta a veces, pero no siempre, se abre la conexión de nuevo en /dev/ttyUSB1 en vez de /dev/ttyUSB0. (Con mas pruebas, errores, frustraciones y busquedas en foros viejos al fin me di cuenta que este problema desaparece con la desinstalación de brltty, un daemon para teclados de braille que solamente Ubuntu tiene instalado “por default”. No entiendo como lo hace pero parece que causa un conflicto). De todos modos siempre hay que asegurar que el gps esta conectado bien viendo o xgps o echo rw | nc localhost 2947, y si no cambiar el comando.

Un problema que encontré era no podía guardar el tracklog en formato gpx para la sincronización con el software de visualización. GPSDrive usa su propio formato .sav y no podia entender como hacerlo en Viking. Aunque gpsbabel puede convertir entre los dos, hay problemas cuando se pierde la señal y se graba con ceros.

La solución mas robusta que encontré fue el uso de gpsd directo para grabar el output del aparato a un archivo. Si el gps esta en el usb empiezas gpsd con

gpsd /dev/ttyUSB0

Luego el comando abajo produce un archivo ligero con todos los datos crudos del GPS.  Se puede apagar la pantalla del laptop y dejarla funcionando  hasta que se acabe la batería

echo rw | nc localhost 2947 > raw.dump

Desafortunadamente en el caso de mi pobre vieja Toshiba la batería dura  menos de 30 minutos. Estoy esperando la entrega de una pequeña Acer one precisamente para este tipo de uso. Se venden estas minilaptops económicas con Linux preinstalado, asi que las instrucciones son relevantes para sus usuarios.

Al terminar de grabar se convierte el archivo en gpx con gpsbabel. (Si quieres una explicación técnica del formato nmea esta diponible aqui http://en.wikipedia.org/wiki/NMEA_0183)

gpsbabel -i nmea -f raw.dump -o gpx -F tracklog.gpx

Ahora lo único que tienes que hacer es correr GPicSync. El interface es intuitivo y no requiere explicación.

He incluido un archivo kmz de Google Earth que acabo de producir con fotos de alta resolución de mi casa aqui.

http://duncanjg.files.wordpress.com/2008/08/casakmzquitaelresto.doc

Este archivo es de 24MB. WordPress no acepta el sufixo de .kmz. Asi que esta disfrazado como doc. Si quieres ver lo hay que esperar un rato para que se baje y luego cambiar el nombre a casa.kmz y luego abrirlo en Google Earth.

Written by Duncan Golicher

August 31, 2008 at 10:20 am

The family on holiday

leave a comment »

Written by Duncan Golicher

August 21, 2008 at 10:29 pm

Maps and perceptions: Recent and historical land use change in Chiapas

leave a comment »

What is a map? Maps clearly correspond to some observable reality, but maps are not simple depictions of something to be found on the ground. When we say a map is unreliable or inaccurate we assume that its use would lead astray, sometimes quite literally. However no map is a perfect representation of “reality”. Many do not even attempt to be so. Maps play an important illustrative role in science. The classic example is the choropleth map. A choropleth map shows political or other units shaded according to the value of some measurement taken on the area as a whole. A choropleth map does not correspond to obervable ground feature. Such maps can be extremely useful as data summaries, but they are also potentially misleading. Choropleths are prone to misinterpretation due to the ecological fallacy or the modifiable areal unit problem. Distortions and biases in perception can also be introduced by the choice of colouring and shading. For example, the map below is based on a cover change analysis carried out by Ecosur and Conservation International. The colouring helps to point out “hotspots” of forest cover change, but may be misleading in a quantitative sense. If a traditional choice of shading in tones of a single colour had been chosen the map would have been difficult to interpret as the use of monochrome tones does not permit municipalities with higher rates of deforestation to stand out. However a division into arbitrary classes that are given contrasting colours is clearly subjective. Despite the flaws of a choropleth map, there is a clear message that can be extracted from the figure above. It is that only comparatively modest overall loss in forest cover has taken place during the last decade and a half in most of the land area of the state of Chiapas. The lowest rates of cover change have occurred in the densely populated highlands. This observation is based on an empirical reality detected by the Landsat sensor. The public perception is quite different. Most residents of the state would suggest a much higher rate of change based on an assumption of large scale extensive recent forest loss.

Putting to one side  technical problems involving classification error and interpretation, there is a larger issue. Why does a reasonably robust analysis appear to contradict public perception? A historical perspective may begin to explain the discrepancy both in a conceptual and  practical manner. Take for example the map of the state of Chiapas provided in the 1858 Atlas of Mexico. Instruments to measure longitude, as opposed to latitude, were still quite unreliable in this period, which may explain the strangely distorted shape of the state. The cartographer clearly used a very subjective impression of distance. The road between Tuxtla and San Cristóbal in these times was in an almost impassably bad condition and has always involved a climb of over 1600 m. The relative distances on the 1858 map thus appear to correspond to time spent travelling rather than actual distances. Compare the 1858 map to current cartography.

If the cartography in 1858 was so inaccurate and subjective I would place little faith in demographic parameters provided by the census of the time.  Yet they too were based on some sort of distorted reality. According to the 1858 atlas the total population of Chiapas was 161,000. This is similar to the present day population of San Cristóbal. However this must be too low. It probably  represents around half the true value.  Acceptance of the figure at face value demands a population growth of over 5% in the second half of the nineteenth century in order to reach the level in 1900. That is unlikely. I would strongly suspect that the most severe undercounts occurred in inaccessible rural areas and indigenous communities, for obvious reasons related to poor communications. Thus it is very interesting to find that the population of the rural Tzotzil speaking “village” of Chamula to the north of San Cristobal was reported to be over 10,000. In 2005 the recorded population of the nuclear centre of Chamula was considerably less, at just under 3000 (It must be pointed out that the population of the whole municipality of Chamula amounts to around 60,000, distributed in numerous dispersed settlements). In 1858 the indigenous  community of Zinacantan was reported to have a population of around 2200. That is not far from the 2005 value of just over 3000.

Thus at least a part of the rural hinterland of the highlands was already populated at levels comparable to the present values by 1858. In contrast the “urban” population of the time was incipient. The “city” of San Cristobal had a population of around 7,500, which compares with  the current value of over 160,000.

Slightly more reliable census data began to be available at the beginning of the century when the recorded population of the state of Chiapas was still just below half a million. The figure below plots both population growth (left axis) and the amount of land granted to the rural population through land reform during the last century (right axis). It would be reasonable to assume that the process of land grants (that largely ceased after 1992) was partly linked to forest clearance, although much of the land may already have been cleared. However, to put demographic growth into perspective, data from the FAO for the entire country of Mexico show that the urban population reached the size of the rural population in 1960. Since then the rural population as a whole has remained static, while the urban population has continued to grow. How does this observation relate to the theme of maps, perceptions and deforestation? The point I demonstrate is that all our perceptions are influenced by what we see around us on a daily basis. Most of the Mexican population (and virtually the entire Mexican middle class) now live in large urban centres. The pace of change of their own surroundings, as the Mexican population exploded during the twentieth century, was vertiginous. Cities such as San Cristobal continue to grow. This has led to a generalised perception of dramatic change across the entire country. Urban dwellers project their own experiences onto a rural hinterland, that is largely unknown to them. The consequence is a feeling that rural areas must have lost a large proportion of their forests in recent years due to population expansion.

In one sense this has occurred. The growth of many cities, such as San Cristóbal has been a consequence of immigration from the rural hinterland. The use of nearby forest has intensified due to the extraction of elements such as charcoal, fuelwood, timber and ornamental plants for the urban market. Migrants have also been granted land in “agricultural frontier” areas such as Marques de Comillas. However intensification in forest use does not necessarily equate to land use change. The number of people that have chosen to remain living in the traditionally populated rural areas has remained remarkably constant. This might explain why the heavily populated rural areas of the Highlands of Chiapas have, in general, not shown notable changes in overall forest cover in the last decade. Deforestation occurred long before this period resulting in a comparatively static overall landscape pattern. The current population of Chiapas is around 4.3 million. Around a quarter of the population live in what could be considered to be truly rural settlements with less than 400 inhabitants (fewer than 100 houses). Thus although the overall population of the state is over eight times larger than at the start of the twentieth century, the proportionate increase in the rural population has been much less. The number of people extracting a livelihood directly from the land may have only doubled. The total area of Chiapas is 73,700 Km2. Approximately 35,000 Km2 is covered by trees or shrubs. In other words less than half the total area of Chiapas is used intensively. Thus the problem associated with deforestation in most of the state should be placed in the context of chronic degradation through over use leading to dominance by secondary species and a loss of ecological integrity and functionality through fragmentation and compositional change. These are subtle effects that are not easily mapped or perceived. In contrast logging or forest fires are highly visible, even if long term overall forest cover is generally resilient to their impacts.

Written by Duncan Golicher

August 16, 2008 at 12:50 pm

Follow

Get every new post delivered to your Inbox.

Join 52 other followers