Working with geospatial data on AWS Ubuntu

I’ve stumbled on different sorts of problems while working with geospatial data on cloud machine. AWS EC2 and Ubuntu sometimes require different setups. This is a quick note for installing GDAL on Ubuntu and how to transfer data from your local machine to your cloud machine without using S3.

To install GDAL

sudo -i
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt upgrade # if you already have gdal 1.11 installed
sudo apt install gdal-bin python-gdal python3-gdal # if you don't have gdal 1.11 already installed

To transfer data (SFTP) from your local machine to AWS EC2, you could use FileZilla.

Another option is using S3 with Cyberduck

To set up the environment, please refer to this post and this video.

How to use the online map tool for investing in sustainable rubber cultivation in tropical Asia如何利用在线地图工具投资热带亚洲可持续天然橡胶种植

Please go ahead and play with the full-screen map here.

This map Application is developed to support the Guidelines for Sustainable Development of Natural Rubber, which led by China Chamber of Commerce of Metals, Minerals & Chemicals Importers & Exporters with supports from World Agroforestry Centre, East and Center Asia Office (ICRAF). Asia produces >90% of global natural rubber primarily in monoculture for highest yield in limited growing areas. Rubber is largely harvested by smallholders in remote, undeveloped areas with limited access to markets, imposing substantial labor and opportunity costs. Typically, rubber plantations are introduced in high productivity areas, pushed onto marginal lands by industrial crops and uses and become marginally profitable for various reasons.




Fig. 1. Rubber plantations in tropical Asia. It brings good fortune for millions of smallholder rubber farmers, but it also causes negative ecological and environmental damages.


The online map tool is developed for smallholder rubber farmers, foreign and domestic natural rubber investors as well as different level of governments.  

The online map tool entitled “Sustainable and Responsible Rubber Cultivation and Investment in Asia”, and it includes two main sections: “Rubber Profits and Biodiversity Conservation” and “Risks, SocioEconomic Factors, and Historical Rubber Price”.



The main user interface looks like the graph (Fig 2). There are 4 theme graphs and maps.


p1_section intro

Fig. 2. The main user interface of the online map tool.


. Section 1 第一部分内容

This graph tells the correlation between “Minimum Profitable Rubber (USD/kg)” (the x-axis of the graph, and “Biodiversity (total species number)” in 2736 county that planted natural rubber trees in eight countries in tropical Asia.  There are 4312 counties in total, and in this map tool, we only present county that has the natural rubber cultivated.


p1_section intro_high

Fig. 3. How to read and use the data from the first graph. Each dot/circle represents a county, the color, and size of it indicates the area of natural rubber are planted. When you move your mouse closer to the dot, you will see “(2.34, 552) 400000 ha @ Xishuangbanna, China”, 2.34 is the minimum profitable rubber price (USD/kg), 552 is the total wildlife species including amphibians, reptiles, mammals, and birds.  “400000 ha” is the total area of planted natural rubber plantation from satellite images between 2010 and 2013. “@ Xishuangbanna, China” is the geolocation of the county. 


Don’t be shy, please go ahead and play with the full-screen map here. The minimum profitable rubber price is the market price for national standard dry rubber products that would help you to start makes profits. For example, if the market price of natural rubber is 2.0 USD/kg in the county your rubber plantation located, but your minimum profitable rubber price is 2.5 USD/kg means you will lose money by just producing rubber products. However, if your minimum profitable rubber price is 1.5 USD/kg means you will still make about 0.5 USD/kg profit from your plantation.


The county that has a lower minimum profitable price for natural rubber is generally going to make better rubber profit in the global natural rubber market. However, as scientists behind this research, we hope that when you rush to invest and plant rubber in a certain county, please also think about other risks, e.g. biodiversity loss, topographic, tropical storm, frost as well as drought risks. They are going to be shown later in this demonstration. 


p2_section intro_high.gif

Fig. 4.  The first map is the “Rubber Cultivation Area”, which shows the each county that has rubber trees from low to high in colors from yellow to red. The second map “Minimum Profitable Rubber Price”(USD/kg), again the higher the minimum profitable price is the fewer rubber profits that farmers and investors are going to receive. The third map is ” Biodiversity (Amphibians, Reptiles, Mammals, and Birds)”,  data was aggregated from IUCN-Redlist and BirdLife International.

图4:第一张地图是“橡胶种植区”,它显示了每个县的橡胶树种植数量从低到高的颜色,即从黄色到红色。第二张图“最低成本”(美元/千克),橡胶的平均成本越高,橡胶园的经营者就会获得更少的利润。第三地图是“生物多样性(两栖动物、爬行动物、哺乳动物和鸟类)”,数据来自世界自然保护联盟红色名录IUCN-Redlist和国际鸟盟聚集BirdLife International

. Section 2 第二部分

We also demonstrated different types of risks that investors and smallholder farmers would face when they invest and plant rubber trees. Rubber tree doesn’t produce rubber latex before 7 years old, and the tree owners won’t make any profit until the tree is around 10 years old in general. In this section, we presented “Topographic Risk”, ” Tropical Storm”, “Drought Risk”,  and “Frost Risk”.


p3_section intro_high.gif

Fig. 5. Section 2 ” Risks, SocioEconomic Factors and Historical Rubber Price” has seven different theme maps and interactive graphs. They are “Topographic Risk”, ” Tropical Storm”, “Drought Risk”,  and “Frost Risk”, “Average Natural Rubber Yield (kg/ha.year)”, “Minimum Wage for the 8 Countries (USD/day)”, and ” 10 years Rubber price”.


If you are interested in how the risk theme maps were produced, Dr. Antje Ahrends and her other coauthors have a peer-reviewed article published in Global Environmental Change in 2015.  “Average Natural Rubber Yield (kg/ha.year)” and “Minimum Wage for the 8 Countries (USD/day)” dataset was obtained from  International Labour Organization (ILO, 2014)  and FAO.” 10 years Rubber price” was scraped from  IndexMudi Natural Rubber Price.

这个互动地图集中展示的所有内容都是有科学依据的。如果你想知道风险专题地图是如何编制的,Antje Ahrends博士和其他合作者有一篇同行评审的论文,发表在2015年的国际期刊《全球环境变化》。“平均天然橡胶产量(公斤/公顷/年)”和“8国家最低工资(元/天)”的数据来自国际劳工组织(ILO,2014年)和联合国粮农组织。“10年橡胶价格”来自于天然橡胶的价格indexmudi。

Dr. Chuck Cannon and I are wrapping up a peer-reviewed journal article to explain the data collection, analysis, and policy recommendations based on the results, and we will share the link to the article once it’s available. Dr. Xu Jianchu and Su Yufang have shaped and provided guidance to shape the online map tool development. We could not gather the datasets and put insights to see how we could cultivate, manage, and invest in natural rubber responsibly without other scientists and researchers study and contribute to field for years. We appreciated Wildlife Conservation Society, many other NGOs and national department of rubber research in Thailand and Cambodia for their supports during our field investigation in 2015 and 2016.

Chuck Cannon博士和我正在撰写一篇同行评议的科研期刊文章,用来解释该地图集生成的数据收集、分析等等,还包括了政策建议。文章一旦发表,我们会和您分享文章的链接。许建初博士和苏宇芳博士为在线地图集的开发提供了非常宝贵的意见和建议。我们无法收集数据集、并在没有其他科学家和研究人员的研究和贡献的情况下深入了解如何才能负责任地种植、管理和投资天然橡胶。我们感谢野生动物保护协会和许多其他非政府组织,以及泰国和柬埔寨国家橡胶研究院在2015和2016年的实地调查中给予的支持。

We have two country reports for natural rubber in Thailand, and natural rubber and land conflict in Cambodia, a report support this online map tool is finalizing and we will share the link soon when it’s ready.



Technical sides 技术层面

The research and analysis were done in R, and you could find my code here.

The visualization is purely coded in R too, isn’t R is such an awesome language? You could see my code for the visualization here.



To render geojson format of multi-polygon, you should use:

county_json_simplified <- ms_simplify(<your geojson file>)

My original geojson for 4000+ county weights about 100M but this code have help to reduce it to 5M, and it renders much faster on

我原来的GeoJSON 4000 +县级文件大小约100兆,但是这行代码有效的使文件降低到5兆。

I learnt a lot from this blog on manipulating geojson with R and another blog on using flexdashboard in R for visualization. Having an open source and general support from R users are great.


A baby step towards my interactive map application using Leaflet JavaScript


This is how my national GDP interactive map looks like on the local host. You could watch my first ever video record on YouTube of this interactive map. A brief introduction of the map and also the codes using HTML, CSS, and JavaScript. This was a very simple example I made to test some of my ideas.

If you remember my last blog that I present an interactive map host via ESRI ArcGIS Online.  After my data was successfully uploaded, I found several issues that I don’t like about it:

  1. Even though ESRI ArcGIS Online have a super nice format that you could visualize the spatial data in a pretty way, but the data loading from the site is very slow, AND IT’S COULD BE VERY EXPENSIVE. I am at my 60 days free trial at this point and I believe if I wanna use the server and do some data analysis on ArcGIS Online I have to buy their credits;
  2. The way of data presenting is restricted to the certain format depends on how you select the web map format from ESRI.

I use quite a bit of R, and I know that there are two packages in R called Shiny and Leaflet For R might help me develop the idea. I was so thrilled to find these packages, I feel a bright light shine on my road and point to the destination I wanna head to, and I found a perfect example that my web map application will look like especially the case of  American Super Zipcode. There are not only an interactive map but also while you zoom in and out you could also show some statistic results on the right side of the map. It’s too cool.

But I was so disappointed too while I found out developing a web application through Shiny and Leaflet for R would not be free, because I still need a server to host my data and APP once they could be share. However, at the point that I only need to test my ideas.

I gave up the two methods I found above and even checked out Mapbox Studio and Cartodb, two of the most popular online interactive map and visualization platform. But they are for developers (you still could use it without coding background, though), but I wanna have some features that require coding in Javascript. Leaflet JavaScript library is the last and best way I could use, which could give me enough freedom to figure out the functions/features for my application, and even the interactive analytical tools that I could put up over there. Now I also find D3 might be even more attractive because it hosts a bigger JS library that not only for the interactive map but also other online interactive way of data visualization.

I got a lot help from briefing through some YouTube videos (that’s the reason I recorded a video myself and hope it could be helpful to another struggling beginner like myself). Learn quite a lot of new things like GeoJson and GeoJson-vt. GeoJson is a geodata format for JavaScript, which is equal to shapefile for ArcGIS and QGIS. If your dataset is bigger than 1 M, the data loading to your website would slow down, so the founder of leaflet JS library wrote a vector tile JS codes (GeoJson-vt) to speed up the shapefile data loading process.

Here is my HTML, CSS and JavaScript code for the application you see in the video, You could also find me and my codes on GitHub


The natural rubber value chain and foreign investments in Thailand: how can we achieve sustainable and responsible rubber cultivation and investment?

I have an opportunity worked for Chinese Ministry of Commerce with ICRAF last fall, and have been studying natural rubber value chain since then. I led four technic reports on natural rubber value chain: the first report is for Thailand natural rubber value chain (please see the title);the second one  is about natural rubber value chain, foreign investments and land conflicts in Cambodia; the third report is the a comparison study between Thailand and Cambodia, the biggest natural rubber producer and the emerging rubber producer; the last report will concentrate on the risks of natural rubber cultivation and investment in Asia, from geosnatially perspectives. As I mentioned in the reports that there are no winner in the natural rubber value chain: we lost biodiversity and ecosystem services from covering natural forests to rubber monoculture (upstream of the value chain); and emitted million tons of polluted air and water, and carbon dioxide back to nature from rubber processing (the midstream); at the end, without sustainable livelihood for the poor who grows rubber; and limited competitiveness in the end products market (the downstream). We should go back the source and really think about how we can improve the whole value chain, and why.

The following content is the abstract of Thailand report in English. These reports are in Chinese recently, if you are interested in the content please contact Dr. Zhuang-Fang Yi, and

Upper Mekong Region

Figure 1. The great Mekong region and also the global nature rubber producers. 

Asia supplies 93% of natural rubber demand globally. As the world No.1 natural rubber producer, Thailand has exported nearly 40% of global rubber production demands, which is 87% of its domestic rubber production. The production improvement in Thailand is not only depending on its biophysical suitability of rubber growing, but also relying on its policy supports and subsidies to millions of upstream rubber farmers. Thailand has spent about 21.3billion Baht (586million USD) from Sep. 2013 to Mar. 2014 to subsidize its rubber farmers while the price of natural rubber went down. However, lack of manufacturing and financial supports for its midstream and downstream of the natural rubber value chain, Thailand highly depends on rubber exporting to other countries, e.g. China, US, EU and Japan.

The long history of natural rubber cultivation and supports from Thai government has grown Thai rubber farmers a better rubber economic resilience cultivation systems, which is rubber agroforestry. Rubber agroforestry is a rather complex intercropping system compare to rubber monoculture. Rubber monoculture refers to the rubber plantations that only have rubber trees, and other plant species has been killed and get rids constantly by using herbicide and manual clearance. Rubber agroforestry sustains better ecosystem services and also bring more economic returns. But the labour requirement and knowledge gaps from rubber monoculture to rubber agroforestry are the main constrains for a greener cultivation system. It means rubber farmers only need to intensively take care rubber trees in rubber monoculture system, but need other knowledge and time inputs for rubber agroforestry. However, there are about 21 intercropping systems and more than 300 farms are practicing the intercropped rubber agroforestry by the rubber famers without authority supports like rubber monoculture in Thailand. Urgent research and institution support are need for rubber agroforestry in Thailand and globally.

The merging economies and natural rubber producer countries, e.g. Vietnam, Cambodia, Laos, and Myanmar in Mekong region, are following Thailand’s foot steps, only practicing rubber monoculture, that highly support its upstream value chain but lack of rubber manufacturing and supporting financing systems for mid-stream and downstream. It leads to heavily depend on Chinese and the rest of world rubber demands. It leads to very weak economic resilience for millions of smallholding rubber farmers when the price goes down. In China market, rubber price dropped from 6.3USD/kg to less than a dollar in 2014. China, as the biggest natural rubber importer, consuming nearly 40% of global rubber supply. On the other hand, 20% of imported taxes are charged and have dramatically increased the cost of rubber end products, and loss its global competitiveness in the natural rubber market. There are no winner in the natural rubber value chain: we lost biodiversity and ecosystem services from covering natural forests to rubber monoculture (upstream of the value chain); and emitted million tons of polluted air and water, and carbon dioxide back to nature from rubber processing (the midstream); at the end, without sustainable livelihood for the poor who grows rubber; and limited competitiveness in the end products market (the downstream). We should go back the source and really think about how we can improve the whole value chain, and why.

While more and more Chinese state-owned and private enterprises follow “Go Global” strategy by Chine central government who have heavily invested outside of China. Natural rubber end products, especially tires industry is one of them. In this reports, we scrutinized the natural rubber value chain in Thailand and its foreign investments , especially Chinese investments. We tried to answer:

  1. If there are the best rubber cultivation systems that combine economic returns and a better ecosystem services supporting system;
  2. The relationship between Chinese investors and Thai natural rubber value chain;
  3. The possible ways of sustainable and responsible rubber cultivation and investment.

Coming reports in Chinese


Figure 2. Thailand as the biggest rubber producer, produce 4.5millions ton of natural rubber, and 80% of Thailand domestic natural rubber is from Southern Thailand. Each polygon represents of a province in the map and the darker of the color represents the bigger area of rubber cultivation.

Data visualization via ArcGIS: from data to information and my Geo-Cases 4 and 5

Spatial analysis through Geographic Information System is very powerful that allows us to dig out the pattern and the message behind the random look data we collected. Geospatial analyst believes that the information is there, and it’s just how we could find it out and visualize it.

ESRI ArcGIS provide several spatial statistics tools, e.g cluster,regression,geogarphic relationship. I am playing with datasets of two separate cases today. First case is mining the crime data of 2008 in Pittsburgh, PA; the second case is analyzing population at risk from earthquakes in California city. The data-sets are provided by ESRI ArcGIS tutorial.

Knowledge needed: Geospatial statistics, mainly on buffering and cluster.

Geo-case 4 crime data mining from Pittsburgh, PA in 2008. The dataset I have here only have larcenies in Pittsburgh from 2008, the data included crime date, locations, the age, gender, race. To map out the larceny frequency for each neighborhood, and the criminal features are what I am going to present here. Group cluster analysis is used to dig out the pattern and message behind these random data.

Map results:

crime data mining in Pittburg-densityFrom the frequency/density of larcenies, there are more larcenies in some area especially the up right corner of the city. However, some areas are safer in term of larceny density, and have marked with a hollow fill.

crime data mining in Pittburgh1

Using group cluster analysis, six groups of larceny criminals are mapped on the map above. Each group contents race, gender and average age of the criminals.

Geo-case 5. Population at risk and number of death from earthquake since 1985.

Result map: Clifornia earthquak risk

Map interpretation: the points on the maps are the earthquakes distribution in California from 1720 to 1994. Only MMI higher than 6 were presented here. MMI,stands for Mercalli Intensity Scale, from 6 to 12 correspond to increasing damage, from considerable damage of poorly constructed buildings through total destruction ( Only death from the earthquakes since 1985 were counted. 440 death and 70% of them are from a earthquake in southern California in 1992. The circles on the map are the areas that significantly impacts by the earthquakes since 1985, and the number labeled are the death.

** data presented here might be modified and uncorrected, and I DON’T TAKE RESPONSIBILITY for the correctness of the information presented here. They are JUST the practice and assignments I’ve done for the professional certification test on ESRI ArcGIS 10.2. Please don’t use THE maps for any other purposes. 


*** I have a legal work permit in the states, and am now open for a job position in Geospatial Analyst/GIS Analyst around DC area (or telecommuting). I have knowledge on: 

  • Utilize advanced modeling techniques
  • Apply fundamental spatial statistics
  • Perform advanced vector and raster analysis
  • Perform surface modeling and analysis
  • Understand and apply python scripting
  • Perform fundamentals of spatial database design
  • Determine and define an appropriate coordinate system
  • Demonstrate proficiency in application configuration
  • Apply advanced visualization techniques
  • Understand fundamental network analysis concepts
  • Perform some basic network analysis

I mainly using ESRI ArcGIS 10.2, ArcGIS online, server, and have experience using open GIS softwares and platforms on QGIS and GRASS, and spatial modeling scripting via R and Python. I will present the knowledge above in the  geo-cases I’m doing in my future blogs. English is my third language, and any comments, proof reading, and advice on language polishing and even the content revision are welcomed.

Everything is spatial and they all can be mapped and my Geo-Case 3.

I majored in Geography for my bachelor degree and did Ecological Economics for my PhD. I often got questions from people asking if I am more an economist or an ecologist, I would say I am more a geographer.  “Oh, I never knew Geography is a major” or “what is that?” If you ever asked me these kind of question, please don’t feel bad about it, because you’re not the only one, and I bet my peers got these questions and response all the time.

One thing you might not know is Geospatial Technology has been listed as the top emerging industry in next decades by United States Department of Labor. To me Geospatial Technology is a combination of art, science and engineering. It’s the art of data visualization, and the thought and skills the analyst/cartographer put behind it. I usually got question about what is my ideal job from friends and family, I would say it’s probably Geographic Information System (GIS) analyst or geospatial analyst within the Geospatial Technology since I moved to the states . It’s difficult to become a good GIS analyst in China, even though China got a huge group of GIS analysts and good Geo-programers because it’s more difficult to access to geo-data there, and the field develops just recently and the fundamental data sources are so limited. You have to work for top research institutes or universities to be able to get the data to do further geospatial analysis, and of course you have to build up the network with the state agents first to be able to have the access to the data. However, the story is so different in the states that you have so much open source database run by the state department, and the people are so willing to share their data, the analysis. I got too excited I guess lol and decide to be one of them….This is a link to more than 300 free GIS datasets shared by Prof. Robin Wilson: Of course, like you’ve just guessed most of free datasets are run and shared by the research institutes, NGO, state lab and universities in the states.

You’re probably would ask about ‘what is exactly geospatial technology?’ I would say they are just the maps you’re using every day, for example, the fastest or least traffic driving routs that google map tells you to get to airport; the map of the best Thai/Mediterranean/Mexican restaurants Yelp shows you; The price of housing around your neighborhood that your real estate agent tells you; or how about the crime map for police station in your area, some area attracts more serious crimes and some are low. Actually, you only need a very basic mapping skill with good platform to map these data that I mentioned above. Of course, you could do more sophisticated analysis with the geo-datasets you have access to, e.g. the medicare spending in some states (countries) are higher than others? Is that because they have less accessibility to good and clean water/food? Or there are just more health facilities happen to be there? Do people become healthier  after they spend more on the medicare and health? Or how about having a protected area in this location and why not a thousand miles away? How much we need to spend on protecting this wildlife? And where would be the most cost-efficient way to fund it?

Everything is spatial and they all can be mapped. Map is so powerful that you definitely could tell the story from the data presents on it. Even though a lot of data is open in the states, but to become a GIS analyst, who works for states department, needs to have a security clearance. It becomes impossible for a non us citizen then. It’s such a dilemma, right? However, there are already such a good and open data source in the states, and I’ve seen so many cool analysis have been presented. Therefore, the work ethics have been highly valued in the field, including what message you’re presenting in the maps and who you present to.

Back to my Geo-Case 3, I had an experience to work with a national nature reserve (state protected area) in China this July. I tried to quantify the habitat quality for future biodiversity conservation under human disturbance and climate change, and to target a location for avoid the impacts from both human disturbance and climate change. We’ve been working with the natural reserve for years and have able to road network, villages location, socioeconomic and demographic data, and historical land-use maps, soil map, vegetation type and so on. My colleagues in World Agroforestry Centre run climate change models, and they impacts on land-use change, which were the land-use change simulation rule for me to run the land-use scenarios.

Data description:  To run this geospatial model of wildlife habitat degradation under human disturbance would need the land- use maps in recent years, climate change data, soil, vegetation type, socioeconomic and demographic and so on. I run the habitat degradation models though InVest (you could get more information through here: It a platform that allow you to value natural capital.

Knowledge need: remote sensing imagery processing for the land-use mapping; Geo-statistics/geospatial through ESRI ArcGIS; InVest, especially, habitat quality and habitat risk management. (Leave me a comment if you need more detail information).

Result maps:


hibitat degredation

No surprise that human disturbance have more impacts on habitat quality in the nature reserve, which you could tell the degraded areas are along the road network; and the core area for the nature reserve, which has the least human disturbance, would maintain the highest habitat quality (yellow corner on the left corner of the map.).

*** I am now open for a job position in Geospatial Analyst/GIS Analyst around DC area (or telecommuting). I have knowledge on: 

  • Utilize advanced modeling techniques
  • Apply fundamental spatial statistics
  • Perform advanced vector and raster analysis
  • Perform surface modeling and analysis
  • Understand and apply python scripting
  • Perform fundamentals of spatial database design
  • Determine and define an appropriate coordinate system
  • Demonstrate proficiency in application configuration
  • Apply advanced visualization techniques
  • Understand fundamental network analysis concepts
  • Perform some basic network analysis

I mainly using ESRI ArcGIS 10.2,  ArcGIS online, server, and have experience using open GIS softwares and platforms on QGIS and GRASS, and spatial modeling scripting via R and Python. I will present the knowledge above in the  geo-cases I’m doing in my future blogs. English is my third language, and any comments, proof reading, and advice on language polishing and even the content revision are welcomed.

Geo-Case 1: how to promote your art activities for the potential market of your company

(In my blog, I will use a lot of abbreviation, one of the most frequent ones would be GIS, which stands for Geographic Information System)

GIS knowledge needed: Geocoding;

Data source: Pennsylvania (GIS Tutorial BOOK 1)

Analysis purpose:  There is an art event sponsored by an arts’ organization in Allison Park, Pittsburgh, called FLUX. The event planners of FLUX would like to know where the event attendees reside for planning and marketing activities in the future. There are only attendees’ ZIP codes have been recorded. So simply, we are going to produce a map for FLUX by using ZIP code that attendees provided to tell where they are from in the area.

Data summery: 1487 attendees, and about 86% of them are from Pennsylvania;

Map result:


Conclusion: FLUX needs more planning and marketing for Pittsburgh, especially the southeast corner, since there are more attendee from that area, and they could be the main customers for the future art events marketing who drove far up to north for the art event. However, there are always more information could be visualized, for example, the age, occupation and so on!